示例#1
0
文件: plugin.go 项目: jonasi/project
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...)
}
示例#2
0
文件: server.go 项目: jonasi/project
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
}