add ServeHTTP to Server/Engin for doing Httptest (#2704)

This commit is contained in:
JackSon_tm.m
2023-01-02 00:24:58 +08:00
committed by GitHub
parent cf6c349118
commit 3e9d0161bc
2 changed files with 93 additions and 0 deletions

View File

@@ -307,3 +307,8 @@ func newCorsRouter(router httpx.Router, headerFn func(http.Header), origins ...s
func (c *corsRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c.middleware(c.Router.ServeHTTP)(w, r)
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.ngin.bindRoutes(s.router)
s.router.ServeHTTP(w, r)
}