Documentation
¶
Index ¶
- func DebugAccessCallback(token string, ip string, resource string, id string) bool
- func FullAccessCallback(_ string, _ string, _ string, _ string) bool
- func StartMultiService(bindAddress string, key string, callback TestAccessFunc) error
- func StartSimpleService(bindAddress string, key string, callback TestAccessFunc) error
- func StopService(timeout int) error
- type TestAccessFunc
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugAccessCallback ¶
DebugAccessCallback returns the global variable debugAccessSuccess. It will log the arguments to the package logger in debug level.
Example ¶
err := StartSimpleService(":8080", "123", DebugAccessCallback)
if err != nil {
// handle error
}
func FullAccessCallback ¶
FullAccessCallback will grant access to every rest request.
Example ¶
err := StartSimpleService(":8080", "123", FullAccessCallback)
if err != nil {
// handle error
}
func StartMultiService ¶
func StartMultiService(bindAddress string, key string, callback TestAccessFunc) error
StartMultiService creates a multi password rest service. The service binds to "/overwrite", "/get", "/check", "/set", "/unset", "/list", "/delete", "/clean". The callback of type TestAccessFunc will be called for every request to determine access.
Example ¶
// Start rest service on localhost:8080 without any access control.
err := StartMultiService(":8080", "123", func(string, string, string, string) bool { return true })
if err != nil {
// handle error
}
func StartSimpleService ¶
func StartSimpleService(bindAddress string, key string, callback TestAccessFunc) error
StartSimpleService creates a single password rest service. The service binds to "/overwrite", "/get", "/check", "/set", "/unset", "/delete". The callback of type TestAccessFunc will be called for every request to determine access.
Example ¶
// Start rest service on localhost:8080 without any access control.
err := StartSimpleService(":8080", "123", func(string, string, string, string) bool { return true })
if err != nil {
// handle error
}
func StopService ¶
StopService will block execution and try to gracefully shut down any rest service during the timout period. The service is guaranteed to be closed at the end of the timeout.