2024-10-26 09:42:51 +00:00
|
|
|
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,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-10-30 15:05:20 +00:00
|
|
|
func StorageFromRequest(r *http.Request) *storage.Storage {
|
2024-10-26 09:42:51 +00:00
|
|
|
store, ok := r.Context().Value(ContextKeyStorage).(*storage.Storage)
|
|
|
|
if !ok {
|
2024-10-30 15:05:20 +00:00
|
|
|
hlog.FromRequest(r).Fatal().Msg("Failed to get storage reference from context")
|
2024-10-26 09:42:51 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return store
|
|
|
|
}
|
2024-10-30 15:05:20 +00:00
|
|
|
|
|
|
|
func NoteIdFromRequest(r *http.Request) string {
|
|
|
|
return r.PathValue("noteId")
|
|
|
|
}
|