Last active
April 20, 2017 21:48
-
-
Save hashbender/cc0eac4e668314be30101a0d713f5277 to your computer and use it in GitHub Desktop.
route declarations
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
//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