func setupGit(auth func(string, string) bool, conf *config.Config) { cachePath := filepath.Join(conf.Home, "cache") repoPath := filepath.Join(conf.Home, "repos") restAPI := rest.NewApi() handler := gitreceive.NewGitHandler(repoPath, cachePath) restAPI.Use(defaultStack...) restAPI.Use(&rest.AuthBasicMiddleware{ Realm: "Pebblescape GIT", Authenticator: auth, }) restAPI.SetApp(rest.AppSimple(func(w rest.ResponseWriter, r *rest.Request) { handler.ServeHTTP(w.(http.ResponseWriter), r.Request) })) http.Handle("/git/", restAPI.MakeHandler()) }
func setupHTTP(auth func(string, string) bool, hostAPI *api.API) { restAPI := rest.NewApi() handler := httpHandler{hostAPI} router, err := rest.MakeRouter( rest.Get("/job", handler.ListJobs), ) if err != nil { log.Fatal(err) } restAPI.Use(defaultStack...) restAPI.Use(&rest.AuthBasicMiddleware{ Realm: "Pebblescape", Authenticator: auth, }) restAPI.Use(&rest.ContentTypeCheckerMiddleware{}) restAPI.SetApp(router) http.Handle("/", restAPI.MakeHandler()) }