func startMartini() { mux := martini.NewRouter() mux.Get("/hello", martiniHandlerWrite) martini := martini.New() martini.Action(mux.Handle) http.ListenAndServe(":"+strconv.Itoa(port), martini) }
func codegangstaMartiniRouterFor(namespaces []string, resources []string) http.Handler { router := martini.NewRouter() martini := martini.New() martini.Action(router.Handle) for _, ns := range namespaces { for _, res := range resources { router.Get("/"+ns+"/"+res, helloHandler) router.Post("/"+ns+"/"+res, helloHandler) router.Get("/"+ns+"/"+res+"/:id", helloHandler) router.Put("/"+ns+"/"+res+"/:id", helloHandler) router.Delete("/"+ns+"/"+res+"/:id", helloHandler) } } return martini }
func loadMartiniSingle(method, path string, handler interface{}) http.Handler { router := martini.NewRouter() switch method { case "GET": router.Get(path, handler) case "POST": router.Post(path, handler) case "PUT": router.Put(path, handler) case "PATCH": router.Patch(path, handler) case "DELETE": router.Delete(path, handler) default: panic("Unknow HTTP method: " + method) } martini := martini.New() martini.Action(router.Handle) return martini }
func loadMartini(routes []route) http.Handler { router := martini.NewRouter() for _, route := range routes { switch route.method { case "GET": router.Get(route.path, martiniHandler) case "POST": router.Post(route.path, martiniHandler) case "PUT": router.Put(route.path, martiniHandler) case "PATCH": router.Patch(route.path, martiniHandler) case "DELETE": router.Delete(route.path, martiniHandler) default: panic("Unknow HTTP method: " + route.method) } } martini := martini.New() martini.Action(router.Handle) return martini }