mirror of
https://github.com/signaller-matrix/signaller.git
synced 2024-11-13 22:21:02 +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 ""
|
|
}
|