Documentation
¶
Index ¶
- func DebugAccessCallback(token string, ip string, resource string, id string) bool
- func EnableTLS(certFile string, keyFile string)
- func FullAccessCallback(_ string, _ string, _ string, _ string) bool
- func StartMultiService(bindAddress string, prefix string, key string, callback TestAccessFunc) error
- func StartSimpleService(bindAddress string, prefix string, key string, callback TestAccessFunc) error
- func StopService(timeout int, bindAddress string, prefix string) 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 }
Output:
func EnableTLS ¶ added in v0.11.0
EnableTLS will set the rest backend to https mode. Must be used before starting a rest sever with accessible paths to a public certificate file and private key file.
func FullAccessCallback ¶
FullAccessCallback will grant access to every rest request.
Example ¶
err := StartSimpleService(":8080", "/", "123", FullAccessCallback) if err != nil { // handle error }
Output:
func StartMultiService ¶
func StartMultiService(bindAddress string, prefix string, key string, callback TestAccessFunc) error
StartMultiService creates a multi password rest service. The service binds to "/prefix/overwrite" (PUT), "/prefix/get" (GET), "/prefix/check" (GET), "/prefix/set" (PUT), "/prefix/unset" (DELETE), "/prefix/exists" (GET), "/prefix/list" (GET), "/prefix/delete" (DELETE), "/prefix/clean" (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 := StartMultiService(":8080", "/prefix", "123", func(string, string, string, string) bool { return true }) if err != nil { // handle error }
Output:
func StartSimpleService ¶
func StartSimpleService(bindAddress string, prefix string, key string, callback TestAccessFunc) error
StartSimpleService creates a single password rest service. The service binds to "/prefix/overwrite" (PUT), "/prefix/get" (GET), "/prefix/check" (GET), "/prefix/set" (PUT), "/prefix/unset" (DELETE), "/prefix/exists" (GET), "/prefix/delete" (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", "/prefix", "123", func(string, string, string, string) bool { return true }) if err != nil { // handle error }
Output: