Created
May 11, 2014 09:57
-
-
Save yvasiyarov/a0f6afdedcde25fc00b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/gocraft/web" | |
"net/http" | |
) | |
type Context struct { | |
HelloCount int | |
} | |
func (c *Context) SayHello(rw web.ResponseWriter, req *web.Request) { | |
rw.Write([]byte("Hello world")) | |
} | |
func main() { | |
router := web.New(Context{}). // Create your router | |
Middleware(web.LoggerMiddleware). // Use some included middleware | |
Middleware(web.ShowErrorsMiddleware). // ... | |
Get("/", (*Context).SayHello) // Add a route | |
http.ListenAndServe("localhost:3000", router) // Start the server! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment