1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-13 01:30:31 +02:00

Better handling in middleware for WebSocket

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2015-05-22 20:26:52 -07:00
parent 95f72a5170
commit e0364caf36
6 changed files with 69 additions and 41 deletions

View File

@ -21,6 +21,11 @@ const (
// For invalid credentials, it sends "401 - Unauthorized" response.
func BasicAuth(fn AuthFunc) echo.HandlerFunc {
return func(c *echo.Context) error {
// Skip for WebSocket
if (c.Request().Header.Get(echo.Upgrade)) == echo.WebSocket {
return nil
}
auth := c.Request().Header.Get(echo.Authorization)
i := 0
code := http.StatusBadRequest