func (p *Plugin) RegisterAPI(service *hateoas.Service) { service.Use(middleware.StripPrefixHandler("/api")) service.Use(api.AddLinkHeaders) routes := middleware.Prefix("/api", service.Routes()...) p.RegisterRoutes(routes...) }
func (p *plugin) Routes() []mohttp.Route { prefix := "/plugins/" + p.name return mohttp.ALL( prefix+"/*splat", middleware.StripPrefixHandler(prefix), mohttp.FromHTTPHandler(p.proxy), ) }
func New(sd string) *Server { s := &Server{ Server: http.NewServer(log15.New("pid", os.Getpid())), stateDir: stateDir(sd), } apiService.Use(middleware.StripPrefixHandler("/api")) s.registerRoutes( webRoutes, middleware.Prefix("/api", apiService.Routes()...), ) t := template.Must(template.ParseGlob("server/templates/*")) s.Use( smiddleware.LogRequest(s.Logger), middleware.GzipHandler, setSrv(s), middleware.Template(t), ) return s }