Documentation ¶
Index ¶
- type ContextKey
- type FilterGate
- func (f *FilterGate) AllowConnection(d device.Interface) (bool, device.MatchResult)
- func (f *FilterGate) DeleteFilter(key string) bool
- func (f *FilterGate) GetAllowedFilters() (Set, bool)
- func (f *FilterGate) GetFilter(key string) (Set, bool)
- func (f *FilterGate) SetFilter(key string, values []interface{}) (Set, bool)
- func (f *FilterGate) VisitAll(visit func(string, Set) bool) int
- type FilterHandler
- type FilterRequest
- type FilterSet
- type FilterStore
- type GateLogger
- type Interface
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey is a custom type for setting keys in a request's context
type FilterGate ¶
type FilterGate struct { FilterStore FilterStore `json:"filters"` AllowedFilters Set `json:"allowedFilters"` // contains filtered or unexported fields }
FilterGate is a concrete implementation of the Interface
func (*FilterGate) AllowConnection ¶
func (f *FilterGate) AllowConnection(d device.Interface) (bool, device.MatchResult)
func (*FilterGate) DeleteFilter ¶
func (f *FilterGate) DeleteFilter(key string) bool
func (*FilterGate) GetAllowedFilters ¶
func (f *FilterGate) GetAllowedFilters() (Set, bool)
type FilterHandler ¶
type FilterHandler struct {
Gate Interface
}
FilterHandler is an http.Handler that can get, add, and delete filters from a devicegate Interface
func (*FilterHandler) DeleteFilter ¶
func (fh *FilterHandler) DeleteFilter(response http.ResponseWriter, request *http.Request)
DeleteFilter is a handler function used to delete a particular filter stored in the gate
func (*FilterHandler) GetFilters ¶
func (fh *FilterHandler) GetFilters(response http.ResponseWriter, request *http.Request)
GetFilters is a handler function that gets all of the filters set on a gate
func (*FilterHandler) UpdateFilters ¶
func (fh *FilterHandler) UpdateFilters(response http.ResponseWriter, request *http.Request)
UpdateFilters is a handler function that updates the filters stored in a gate
type FilterRequest ¶
type FilterRequest struct { Key string `json:"key"` Values []interface{} `json:"values"` }
type FilterSet ¶
type FilterSet struct { Set map[interface{}]bool // contains filtered or unexported fields }
FilterSet is a concrete type that implements the Set interface
func (*FilterSet) MarshalJSON ¶
type FilterStore ¶
FilterStore can be used to store filters in the Interface
type GateLogger ¶
GateLogger is used to log extra details about the gate
func (GateLogger) LogFilters ¶
func (gl GateLogger) LogFilters(next http.Handler) http.Handler
LogFilters is a decorator that logs the updated filters list and writes the updated list in the response body
type Interface ¶
type Interface interface { device.Filter // VisitAll applies the given visitor function to each set of filter values // // No methods on this Interface should be called from within the visitor function, or // a deadlock will likely occur. VisitAll(visit func(string, Set) bool) int // GetFilter returns the set of filter values associated with a filter key and a bool // that is true if the key was found, false if it doesn't exist. GetFilter(key string) (Set, bool) // SetFilter saves the filter values and filter key to filter by. It returns a Set of the old values and a // bool that is true if the filter key did not previously exist and false if the filter key had existed beforehand. SetFilter(key string, values []interface{}) (Set, bool) // DeleteFilter deletes a filter key. This completely removes all filter values associated with that key as well. // Returns true if key had existed and values actually deleted, and false if key was not found. DeleteFilter(key string) bool // GetAllowedFilters returns the set of filters that devices are allowed to be filtered by. Also returns a // bool that is true if there are allowed filters set, and false if there aren't (meaning that all filters are allowed) GetAllowedFilters() (Set, bool) }
Interface is a gate interface specifically for filtering devices