Skip to content

Instantly share code, notes, and snippets.

@technosophos
Created November 22, 2013 04:37
Show Gist options
  • Select an option

  • Save technosophos/7594919 to your computer and use it in GitHub Desktop.

Select an option

Save technosophos/7594919 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/Masterminds/cookoo"
"github.com/Masterminds/cookoo/web"
"html/template"
)
func main() {
registry, router, context := cookoo.Cookoo()
tpl := template.Must(template.New("main").ParseGlob("*.html"))
context.Add("tpl", tpl)
registry.Route("GET /", "The default home page").
Does(cookoo.AddToContext, "_").
Using("Title").WithDefault("Hello").
Using("Content").WithDefault("Hi there!").
Does(web.RenderHTML, "html").
Using("template").From("cxt:tpl").
Using("templateName").WithDefault("index.html").
Does(web.Flush, "out").
Using("content").From("cxt:html").
Using("contentType").WithDefault("text/html")
web.Serve(registry, router, context)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment