Documentation ¶
Overview ¶
Package locker provides an HTTP middleware which allows an HTTPHandler to be locked, returning 423 (locked)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Inject ¶
func Inject(other generichttp.HTTPer, l ManipulableLock)
Inject adds a lock route to a generichttp.HTTPer which is used to manipulate the locker
Types ¶
type AxisLocker ¶
type AxisLocker struct {
// contains filtered or unexported fields
}
AxisLocker is a Locker, but for multi-axis devices, enabling granular locks (per-axis)
func (*AxisLocker) Check ¶
func (al *AxisLocker) Check(next http.Handler) http.Handler
Check is an HTTP middleware that implements the locker
func (*AxisLocker) HTTPGet ¶
func (al *AxisLocker) HTTPGet(w http.ResponseWriter, r *http.Request)
HTTPGet returns Locked() over HTTP as JSON
func (*AxisLocker) HTTPSet ¶
func (al *AxisLocker) HTTPSet(w http.ResponseWriter, r *http.Request)
HTTPSet calls Lock or Unlock based on json:bool on the request body
type Locker ¶
type Locker struct { // DoNotProtect is a list of paths not to apply the lock to DoNotProtect []string // contains filtered or unexported fields }
Locker is a type which behaves like a sync.Mutex without the blocking, and holds a list of routes (Goji patterns) to not protext
func (*Locker) Check ¶
Check is an HTTP middleware that returns http.StatusLocked if Locked() is true, otherwise passes down the line
func (*Locker) HTTPGet ¶
func (l *Locker) HTTPGet(w http.ResponseWriter, r *http.Request)
HTTPGet returns Locked() over HTTP as JSON
type ManipulableLock ¶
type ManipulableLock interface { // Check checks if the resource is locked, and is a middleware Check(http.Handler) http.Handler // Get returns the status of the lock HTTPGet(http.ResponseWriter, *http.Request) // Set changes the status of the lock HTTPSet(http.ResponseWriter, *http.Request) }
ManipulableLock describes a lock that can be checked and manipulated