Skip to content

Instantly share code, notes, and snippets.

@hashbender
Last active April 20, 2017 21:48
Show Gist options
  • Save hashbender/cc0eac4e668314be30101a0d713f5277 to your computer and use it in GitHub Desktop.
Save hashbender/cc0eac4e668314be30101a0d713f5277 to your computer and use it in GitHub Desktop.
route declarations
//Route this struct is used for declaring a route
type Route struct {
Name string
Method []string
Pattern string
ContextedHandler *ContextedHandler
}
//Routes just stores our Route declarations
type Routes []Route
//Here we declare the routes. This is a central place for
var routes = Routes{
Route{
"HelloWorld",
//You can handle more than just GET requests here, but for this tutorial we'll just do GETs
[]string{"GET"},
"/hello",
// We defined HelloWorldHandler in Part1
&ContextedHandler{&appContext, HelloWorldHandler},
},
Route{
"GoodbyeWorld",
[]string{"GET"},
"/goodbye",
// GoodbyeWorldHandler is defined outside the gist :)
&ContextedHandler{&appContext, GoodbyeWorldHandler},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment