User login and creation

This commit is contained in:
Caleb Gardner
2024-05-24 04:26:24 -05:00
parent e4f8b31e29
commit 144f45293b
4 changed files with 156 additions and 18 deletions
+3
View File
@@ -19,6 +19,9 @@ type ParsedHeader struct {
k *ApiKey
}
// Parses the X-API-Key and Authorization headers. If the API Key provided but invalid (either due to expiring or isn't found),
// ErrApiKeyUnauthorized is part of the returned error (check with errors.Is).
// If the Authorization header is present but invalid, ErrTokenUnauthorized is part of the returned error (check with errors.Is).
func (b *Backend) ParseHeader(r *http.Request) (ParsedHeader, error) {
out := ParsedHeader{}
key := r.Header.Get("X-API-Key")