This commit is contained in:
crusader 2018-04-06 12:54:22 +09:00
parent e059d8e0fd
commit aa66a49925
2 changed files with 4 additions and 4 deletions

View File

@ -59,6 +59,7 @@ func (sh *ServerHandlers) Destroy(serverCtx server.ServerCtx) {
}
func (sh *ServerHandlers) OnError(serverCtx server.ServerCtx, ctx *fasthttp.RequestCtx, status int, reason error) {
ctx.Error(reason.Error(), status)
}
func (sh *ServerHandlers) RegisterServlet(contextPath string, servlet Servlet) {

View File

@ -135,11 +135,10 @@ func (s *Server) handleServer(listener net.Listener) error {
func (s *Server) httpHandler(ctx *fasthttp.RequestCtx) {
var (
servlet Servlet
err error
)
if servlet = s.ServerHandler.(ServerHandler).Servlet(s.ctx, ctx); nil == servlet {
s.onError(ctx, fasthttp.StatusNotFound, err)
if servlet = s.ServerHandler.Servlet(s.ctx, ctx); nil == servlet {
s.onError(ctx, fasthttp.StatusNotFound, fmt.Errorf("Not Found"))
return
}
servletCtx := servlet.ServletCtx(s.ctx)
@ -148,5 +147,5 @@ func (s *Server) httpHandler(ctx *fasthttp.RequestCtx) {
}
func (s *Server) onError(ctx *fasthttp.RequestCtx, status int, reason error) {
s.ServerHandler.(ServerHandler).OnError(s.ctx, ctx, status, reason)
s.ServerHandler.OnError(s.ctx, ctx, status, reason)
}