22 lines
450 B
Go
22 lines
450 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"gitlab.com/mstarongitlab/goutils/other"
|
|
"gitlab.com/mstarongitlab/linstrom/storage"
|
|
)
|
|
|
|
func StorageFromRequest(w http.ResponseWriter, r *http.Request) *storage.Storage {
|
|
store, ok := r.Context().Value(ContextKeyStorage).(*storage.Storage)
|
|
if !ok {
|
|
other.HttpErr(
|
|
w,
|
|
HttpErrIdMissingContextValue,
|
|
"Missing storage reference",
|
|
http.StatusInternalServerError,
|
|
)
|
|
return nil
|
|
}
|
|
return store
|
|
}
|