mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
19 lines
431 B
Go
19 lines
431 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/formancehq/stack/libs/go-libs/api"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func ReadOnly(h http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet && r.Method != http.MethodOptions && r.Method != http.MethodHead {
|
|
api.BadRequest(w, "READ_ONLY", errors.New("Read only mode"))
|
|
return
|
|
}
|
|
h.ServeHTTP(w, r)
|
|
})
|
|
}
|