Last active
August 29, 2015 14:17
-
-
Save jochasinga/ec631193104d3ef0bc64 to your computer and use it in GitHub Desktop.
URL endpoints for REST APIs
This file contains hidden or 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 ( | |
mux "github.com/julienschmidt/httprouter" | |
) | |
type Route struct { | |
Method string | |
Path string | |
Handle mux.Handle // httprouter package as mux | |
} | |
type Routes []Route | |
var routes = Routes{ | |
Route{ | |
"GET", | |
"/", | |
Index, | |
}, | |
Route{ | |
"GET", | |
"/posts" | |
PostIndex, | |
}, | |
Route{ | |
"GET", | |
"/posts/:id", | |
PostShow, | |
}, | |
Route{ | |
"POST", | |
"/posts", | |
PostCreate, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment