MCPcopy Create free account
hub / github.com/devfeel/dotweb / transferStaticFileHandler

Function transferStaticFileHandler

router.go:689–706  ·  view source on GitHub ↗

transferStaticFileHandler transfer http.Handler to HttpHandle

(fileHandler http.Handler, excludeExtension []string)

Source from the content-addressed store, hash-verified

687
688// transferStaticFileHandler transfer http.Handler to HttpHandle
689func 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
709func (r *router) existsRouter(method, path string) bool {

Callers 1

wrapFileHandleMethod · 0.85

Calls 5

WriterMethod · 0.80
RequestMethod · 0.65
HttpServerMethod · 0.65
ServeHTTPMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected