Skip to content

Instantly share code, notes, and snippets.

@gsingharoy
Created September 30, 2017 16:24
Show Gist options
  • Save gsingharoy/f88b24ebdff61727c6fe9f95d2d2dfb0 to your computer and use it in GitHub Desktop.
Save gsingharoy/f88b24ebdff61727c6fe9f95d2d2dfb0 to your computer and use it in GitHub Desktop.
package main
import "github.com/julienschmidt/httprouter"
/*
Define all the routes here.
A new Route entry passed to the routes slice will be automatically
translated to a handler with the NewRouter() function
*/
type Route struct {
Name string
Method string
Path string
HandlerFunc httprouter.Handle
}
type Routes []Route
func AllRoutes() Routes {
routes := Routes{
Route{"Index", "GET", "/", Index},
Route{"BookIndex", "GET", "/books", BookIndex},
Route{"Bookshow", "GET", "/books/:isdn", BookShow},
Route{"Bookshow", "POST", "/books", BookCreate},
}
return routes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment