1. What is served?

served is a simple web server written in Go. It serves three kinds of content:

In addition to a great HTTP library, the Go authors provided some very useful libraries and code for blogging:

served puts a framework around these that allows you to configure servers that respond on different ports, hosts, and paths.

2. The configuration file

served's configuration file is a simple JSON file. Servers can be defined to listen on unique addresses. Each server can support responding to multiple host names.

3. Setting up a static site

Static sites need to specify a web root ending in "/" and a folder on disk:

                    "VDirs": [
                        { "Root": "/", "Folder": "/Users/michael/web/skyegg" },
                        { "Root": "/gopher/static/", "Folder": "/Users/michael/gocode/src/" }

4. Setting up a blog

In addition to the settings for a static site, blogs need to specify the number of articles to show on the home page, the number of articles to list in the atom feed, and the feed title:

                    "Blogs": [
                        { "Root": "/gopher/", "Folder": "/Users/michael/gocode/src/", "HomeArticles": 5, "FeedArticles": 10, "FeedTitle": "served" }

The blog folder must have a template folder (for the go templates for the site) and a content folder (for articles, slides, and other content). Additionally, there should be a static folder configured as a VDir to hold some web content needed by the templates. Sames of these are available on GitHub.

5. Enabling "play" mode

If you enable play mode, users can compile and execute Go code from the web page! This should probably not be enabled on a public web site, however. served has not been particularly hardened.

                    "PlayEnabled": true,
                    "NativeClient": false

6. Slideshows

When a blog is configured, you can view articles and slide shows in an alternate format by using the "slides" URL:

7. Present markup

The following sections show some of the things you can do with present format.

8. Preformatted text

Simply indent to get preformatted text.

This is preformatted.

9. Showing code from another file

.code puzz.go /^const/,/^\)/
const (
    K = "GOTHACK"

10. Bullets

- bullets
- more bullets

11. Images

.image gopher640.jpg 400 400

12. Play Code

.play puzz.go
package main

import (

const (
    K = "GOTHACK"

func main() {
    for _, c := range C {
        fmt.Printf("%c", A1[strings.Index(A2, string(c))])

13. Use an iframe

.iframe puzz.go 500 500

14. Links

.link Yahoo!
Another format is [[][Google]]

Another format is Google

15. HTML

.html table.html
Column 1Column 2


Michael Lore