Serverside stuff. Mostly shuffling things around
This commit is contained in:
parent
90667d96c7
commit
be70109c43
20 changed files with 513 additions and 71 deletions
33
server/utils.go
Normal file
33
server/utils.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/rs/zerolog/hlog"
|
||||
"gitlab.com/mstarongitlab/goutils/other"
|
||||
"gitlab.com/mstarongitlab/linstrom/storage"
|
||||
)
|
||||
|
||||
func placeholderEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
hlog.FromRequest(r).Error().Stringer("url", r.URL).Msg("Placeholder endpoint accessed")
|
||||
other.HttpErr(
|
||||
w,
|
||||
HttpErrIdPlaceholder,
|
||||
"Endpoint not implemented yet, this is a placeholder",
|
||||
http.StatusInternalServerError,
|
||||
)
|
||||
}
|
||||
|
||||
func getStorageFromRequest(w http.ResponseWriter, 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,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
return store
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue