ing
This commit is contained in:
		
							parent
							
								
									6bf0de295a
								
							
						
					
					
						commit
						f5f96c0292
					
				@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user