More work on the API. Primarely defining jsonapi types
This commit is contained in:
parent
4f4d05a335
commit
0ed50aca60
13 changed files with 165 additions and 48 deletions
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue