More work on the API. Primarely defining jsonapi types

This commit is contained in:
Melody Becker 2024-10-30 16:05:20 +01:00
parent 4f4d05a335
commit 0ed50aca60
13 changed files with 165 additions and 48 deletions

View file

@ -18,16 +18,15 @@ func placeholderEndpoint(w http.ResponseWriter, r *http.Request) {
)
}
func getStorageFromRequest(w http.ResponseWriter, r *http.Request) *storage.Storage {
func StorageFromRequest(r *http.Request) *storage.Storage {
store, ok := r.Context().Value(ContextKeyStorage).(*storage.Storage)
if !ok {
other.HttpErr(
w,
HttpErrIdMissingContextValue,
"Missing storage in context",
http.StatusInternalServerError,
)
hlog.FromRequest(r).Fatal().Msg("Failed to get storage reference from context")
return nil
}
return store
}
func NoteIdFromRequest(r *http.Request) string {
return r.PathValue("noteId")
}