Documentation ¶
Index ¶
- func CompareInsensitive(a, b string) bool
- func DBHandler(selectionFunction HandlerSelectionFunction, fallback Handler, ...) (HandlerFunc, error)
- func DefaultMux(fallbackLocation string) *ServeMux
- func MapHandler(dataStore interface{}, selectionFunction HandlerSelectionFunction, ...) HandlerFunc
- func SelectHandler(reqPath string, dataStore interface{}, tableName string, ...) (Handler, string)
- func YAMLHandler(yaml []byte, selectionFunction HandlerSelectionFunction, fallback Handler, ...) (HandlerFunc, error)
- type HandlerSelectionFunction
- type ServerWriter
- type YamlConfig
- type YamlMapping
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DBHandler ¶
func DBHandler(selectionFunction HandlerSelectionFunction, fallback Handler, fallbackLocation string) (HandlerFunc, error)
func DefaultMux ¶
func DefaultMux(fallbackLocation string) *ServeMux
func MapHandler ¶
func MapHandler(dataStore interface{}, selectionFunction HandlerSelectionFunction, fallback Handler, fallbackLocation string) HandlerFunc
MapHandler will return an http.HandlerFunc (which also implements http.Handler) that will attempt to map any paths (keys in the map) to their corresponding URL (values that each key in the map points to, in string format). If the path is not provided in the map, then the fallback http.Handler will be called instead.
func SelectHandler ¶
func SelectHandler(reqPath string, dataStore interface{}, tableName string, fallbackHandler Handler, fallbackLocation string) (Handler, string)
NOTES: 1) Too many params 2) tableName is not needed in info in string map and not in DB
func YAMLHandler ¶
func YAMLHandler(yaml []byte, selectionFunction HandlerSelectionFunction, fallback Handler, fallbackLocation string) (HandlerFunc, error)
YAMLHandler will parse the provided YAML and then return an http.HandlerFunc (which also implements http.Handler) that will attempt to map any paths to their corresponding URL. If the path is not provided in the YAML, then the fallback http.Handler will be called instead.
YAML is expected to be in the format:
- path: /some-path url: https://www.some-url.com/demo
The only errors that can be returned all related to having invalid YAML data.
See MapHandler to create a similar http.HandlerFunc via a mapping of paths to urls.
Types ¶
type HandlerSelectionFunction ¶
func CreateSelectionFunction ¶
func CreateSelectionFunction(tableName string) HandlerSelectionFunction
NOTE: tableName has nothing to do with the purpose of the function
type ServerWriter ¶
type ServerWriter struct {
// contains filtered or unexported fields
}
func (*ServerWriter) Header ¶
func (s *ServerWriter) Header() http.Header
func (*ServerWriter) WriteHeader ¶
func (s *ServerWriter) WriteHeader(code int) http.Header
type YamlConfig ¶
type YamlConfig struct {
Mappings []YamlMapping `yaml:mappings`
}