-
-
Save anhnguyen1618/04b7671ff74b450aba26e0e8f8af1196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
failed | |
func ApplyMiddleware(rawHandler http.HandlerFunc, middleWares ...Adapter) http.Handler { | |
// Convert rawHandler from type http.HandlerFunc to type http.Handler | |
convertedHandler := http.HandlerFunc(rawHandler) | |
for i := len(middleWares) - 1; i >= 0; i-- { | |
convertedHandler = middleWares[i](convertedHandler) | |
} | |
return convertedHandler | |
} | |
// ok | |
func ApplyMiddleware(rawHandler http.HandlerFunc, middleWares ...Adapter) http.Handler { | |
// Convert rawHandler from type http.HandlerFunc to type http.Handler | |
convertedHandler := func(f http.HandlerFunc) http.Handler { | |
return http.HandlerFunc(f) | |
}(rawHandler) | |
for i := len(middleWares) - 1; i >= 0; i-- { | |
convertedHandler = middleWares[i](convertedHandler) | |
} | |
return convertedHandler | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment