func newServe() *echo.Echo { serve := echo.New() serve.Use(mw.Recover()) serve.Use(beforeRequest()) serve.Hook(splitPath) // 获取新的路径,在请求之前发生 registerRoutes(serve) return serve }
func newServeMux() *echo.Echo { mux := echo.New() // Apply some useful middleware. mux.Use(mw.Logger()) mux.Use(mw.Recover()) mux.Use(mw.Gzip()) return mux }
func NewHttpServer(s *Server) *echo.Echo { // Echo instance e := echo.New() e.SetHTTPErrorHandler(httpErrorHandler) // Logger e.Use(Logger()) e.Use(mw.Recover()) e.Static("/public", s.Config.StaticPath) e.Get("/health", s.healthHandler) g := e.Group("/api", middleAuth(s)) //Routes g.Post("/upload", s.upload) return e }