Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (25 sloc) 621 Bytes
package main
import (
"fmt"
"github.com/gocraft/web"
"github.com/pilu/fresh/runner/runnerutils"
"net/http"
)
func runnerMiddleware(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc) {
if runnerutils.HasErrors() {
runnerutils.RenderError(rw)
return
}
next(rw, req)
}
type Context struct{}
func (c *Context) SayHello(rw web.ResponseWriter, req *web.Request) {
fmt.Fprint(rw, "Hello World")
}
func main() {
router := web.New(Context{}).
Middleware(web.LoggerMiddleware).
Middleware(runnerMiddleware).
Get("/", (*Context).SayHello)
http.ListenAndServe("localhost:3000", router)
}