33 lines
782 B
Go
33 lines
782 B
Go
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
|
|
}
|