From f5f96c0292376021f82bf48eadc342cd8ccb4536 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 10 Apr 2018 23:13:24 +0900 Subject: [PATCH] ing --- web/fasthttp/server-handler.go | 2 +- web/fasthttp/servlet.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web/fasthttp/server-handler.go b/web/fasthttp/server-handler.go index 8cbc74b..aee1f42 100644 --- a/web/fasthttp/server-handler.go +++ b/web/fasthttp/server-handler.go @@ -99,7 +99,7 @@ func (sh *ServerHandlers) RegisterServlet(contextPath string, servlet Servlet) { if nil == sh.servlets { sh.servlets = make(map[string]Servlet) } - servlet.(*Servlets).ContextPath = contextPath + servlet.setContextPath(contextPath) sh.servlets[contextPath] = servlet } diff --git a/web/fasthttp/servlet.go b/web/fasthttp/servlet.go index 15ff414..d227edf 100644 --- a/web/fasthttp/servlet.go +++ b/web/fasthttp/servlet.go @@ -13,6 +13,7 @@ type Servlet interface { Handle(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) *web.Error RequestPath(ctx *fasthttp.RequestCtx) string + setContextPath(contextPath string) } type Servlets struct { @@ -45,6 +46,10 @@ func (s *Servlets) Handle(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx return nil } +func (s *Servlets) setContextPath(contextPath string) { + s.ContextPath = contextPath +} + func (s *Servlets) RequestPath(ctx *fasthttp.RequestCtx) string { return strings.Replace(string(ctx.Path()), s.ContextPath, "", -1) }