signaller/internal/tokenutils.go
2019-07-22 19:46:11 +05:00

25 lines
372 B
Go

package internal
import (
"net/http"
"strings"
)
// getTokenFromResponse returns token from request.
func getTokenFromResponse(r *http.Request) string {
const prefix = "Bearer "
auth, ok := r.Header["Authorization"]
if !ok {
return ""
}
for _, v := range auth {
if strings.HasPrefix(v, prefix) {
return strings.TrimPrefix(v, prefix)
}
}
return ""
}