refactor(http): api key cache handling (#1632)

This commit is contained in:
ze0s 2024-08-28 16:51:03 +02:00 committed by GitHub
parent 0d53f7e5fc
commit d13b421c42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 117 additions and 50 deletions

View file

@ -17,7 +17,6 @@ import (
type apikeyService interface {
List(ctx context.Context) ([]domain.APIKey, error)
Store(ctx context.Context, key *domain.APIKey) error
Update(ctx context.Context, key *domain.APIKey) error
Delete(ctx context.Context, key string) error
ValidateAPIKey(ctx context.Context, token string) bool
}
@ -51,18 +50,14 @@ func (h apikeyHandler) list(w http.ResponseWriter, r *http.Request) {
}
func (h apikeyHandler) store(w http.ResponseWriter, r *http.Request) {
var (
ctx = r.Context()
data domain.APIKey
)
var data domain.APIKey
if err := json.NewDecoder(r.Body).Decode(&data); err != nil {
h.encoder.Error(w, err)
return
}
if err := h.service.Store(ctx, &data); err != nil {
if err := h.service.Store(r.Context(), &data); err != nil {
h.encoder.Error(w, err)
return
}