Beispiel #1
0
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...)
}
Beispiel #2
0
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
}