ing
This commit is contained in:
parent
40422f2d22
commit
6bf0de295a
|
@ -99,6 +99,7 @@ func (sh *ServerHandlers) RegisterServlet(contextPath string, servlet Servlet) {
|
|||
if nil == sh.servlets {
|
||||
sh.servlets = make(map[string]Servlet)
|
||||
}
|
||||
servlet.(*Servlets).ContextPath = contextPath
|
||||
sh.servlets[contextPath] = servlet
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package fasthttp
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.loafle.net/commons/server-go"
|
||||
"git.loafle.net/commons/server-go/web"
|
||||
"github.com/valyala/fasthttp"
|
||||
|
@ -10,10 +12,13 @@ type Servlet interface {
|
|||
web.Servlet
|
||||
|
||||
Handle(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) *web.Error
|
||||
RequestPath(ctx *fasthttp.RequestCtx) string
|
||||
}
|
||||
|
||||
type Servlets struct {
|
||||
Servlet
|
||||
|
||||
ContextPath string
|
||||
}
|
||||
|
||||
func (s *Servlets) ServletCtx(serverCtx server.ServerCtx) server.ServletCtx {
|
||||
|
@ -39,3 +44,7 @@ func (s *Servlets) Destroy(serverCtx server.ServerCtx) {
|
|||
func (s *Servlets) Handle(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) *web.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Servlets) RequestPath(ctx *fasthttp.RequestCtx) string {
|
||||
return strings.Replace(string(ctx.Path()), s.ContextPath, "", -1)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user