cleanup, ensure haproxy is running and disallow writes to followers

This commit is contained in:
ston1th 2021-10-09 19:03:08 +02:00
commit fef86deac8
9 changed files with 49 additions and 183 deletions

View file

@ -14,9 +14,10 @@ import (
)
type ContextData struct {
Net netalloc.Allocator
DB *db.DB
Auth *Auth
Net netalloc.Allocator
DB *db.DB
Auth *Auth
Leader bool
}
func NewContext(w http.ResponseWriter, r *http.Request, data *ContextData, log logr.Logger) *Context {
@ -42,6 +43,10 @@ type Context struct {
Log logr.Logger
}
func (c *Context) Leader() bool {
return c.Data.Leader
}
// Method returns the request method
func (c *Context) Method() string {
return c.Request.Method

View file

@ -43,4 +43,5 @@ var (
ErrMNA = newError("method not allowed", http.StatusMethodNotAllowed)
ErrExists = newError("resource already exists", http.StatusConflict)
ErrISE = newError("internal server error", http.StatusInternalServerError)
ErrFollower = newError("follower write forbidden", http.StatusForbidden)
)