transferStaticFileHandler transfer http.Handler to HttpHandle
(fileHandler http.Handler, excludeExtension []string)
| 687 | |
| 688 | // transferStaticFileHandler transfer http.Handler to HttpHandle |
| 689 | func transferStaticFileHandler(fileHandler http.Handler, excludeExtension []string) HttpHandle { |
| 690 | return func(httpCtx Context) error { |
| 691 | needDefaultHandle := true |
| 692 | if excludeExtension != nil && !strings.HasSuffix(httpCtx.Request().URL.Path, "/") { |
| 693 | for _, v := range excludeExtension { |
| 694 | if strings.HasSuffix(httpCtx.Request().URL.Path, v) { |
| 695 | httpCtx.HttpServer().DotApp.NotFoundHandler(httpCtx) |
| 696 | needDefaultHandle = false |
| 697 | break |
| 698 | } |
| 699 | } |
| 700 | } |
| 701 | if needDefaultHandle { |
| 702 | fileHandler.ServeHTTP(httpCtx.Response().Writer(), httpCtx.Request().Request) |
| 703 | } |
| 704 | return nil |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | // existsRouter check is exists with method and path in current router |
| 709 | func (r *router) existsRouter(method, path string) bool { |
no test coverage detected