mirror of
https://github.com/labstack/echo.git
synced 2025-07-05 00:58:47 +02:00
Fixed basic-auth middleware
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
@ -13,6 +13,7 @@ type (
|
|||||||
Skipper Skipper
|
Skipper Skipper
|
||||||
|
|
||||||
// Validator is a function to validate BasicAuth credentials.
|
// Validator is a function to validate BasicAuth credentials.
|
||||||
|
// Required.
|
||||||
Validator BasicAuthValidator
|
Validator BasicAuthValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +47,9 @@ func BasicAuth(fn BasicAuthValidator) echo.MiddlewareFunc {
|
|||||||
// See `BasicAuth()`.
|
// See `BasicAuth()`.
|
||||||
func BasicAuthWithConfig(config BasicAuthConfig) echo.MiddlewareFunc {
|
func BasicAuthWithConfig(config BasicAuthConfig) echo.MiddlewareFunc {
|
||||||
// Defaults
|
// Defaults
|
||||||
|
if config.Validator == nil {
|
||||||
|
panic("basic-auth middleware requires validator function")
|
||||||
|
}
|
||||||
if config.Skipper == nil {
|
if config.Skipper == nil {
|
||||||
config.Skipper = DefaultBasicAuthConfig.Skipper
|
config.Skipper = DefaultBasicAuthConfig.Skipper
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func WWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NonWWWRedirect redirects WWW request to non WWW.
|
// NonWWWRedirect redirects WWW requests to non WWW.
|
||||||
// For example, http://www.labstack.com will be redirect to http://labstack.com.
|
// For example, http://www.labstack.com will be redirect to http://labstack.com.
|
||||||
//
|
//
|
||||||
// Usage `Echo#Pre(NonWWWRedirect())`
|
// Usage `Echo#Pre(NonWWWRedirect())`
|
||||||
|
Reference in New Issue
Block a user