mirror of
https://github.com/signaller-matrix/signaller.git
synced 2024-11-22 10:22:21 +00:00
25 lines
372 B
Go
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 ""
|
|
}
|