Skip to content

Instantly share code, notes, and snippets.

@jochasinga
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jochasinga/ec631193104d3ef0bc64 to your computer and use it in GitHub Desktop.
Save jochasinga/ec631193104d3ef0bc64 to your computer and use it in GitHub Desktop.
URL endpoints for REST APIs
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