Documentation ¶
Index ¶
- Constants
- Variables
- func Admin(token auth.Token) http.Header
- func Bearer(token auth.Token) http.Header
- func CleanupDB(db *bolt.DB) error
- func ExpectResponse(h http.Handler, url, method string, bodySend, into, bodyExpect interface{}, ...) error
- func FindAll(tx *bolt.Tx, bucket []byte) ([][]byte, [][]byte, error)
- func FindForKeys(tx *bolt.Tx, bucket []byte, keys ...[]byte) ([][]byte, error)
- func FindSession(db *bolt.DB, expiration time.Time) (*auth.Session, error)
- func GetSession(userID string, sesh *auth.Session, db *bolt.DB) error
- func GetWSClient(token, urlStr string) (*ws.Conn, error)
- func MakeLogin(name, pw string, db *bolt.DB) (*auth.Login, error)
- func Options(methods ...string) http.Header
- func Sha256(str string) []byte
- func TempDB(name string) (*bolt.DB, string, error)
- func WSAuthProtocols(token auth.Token) []string
- type Timer
Constants ¶
const ( ShortWait = 20 * time.Millisecond LongWait = 300 * time.Millisecond CleanupWait = 10 * time.Millisecond VeryLongWait = 3 * time.Second )
Timeout constants.
Variables ¶
var FailHeader = http.Header{
"Content-Type": {"text/plain; charset=utf-8"},
"X-Content-Type-Options": {"nosniff"},
}
var OKHeader = http.Header{ "Content-Type": []string{"text/plain; charset=utf-8"}, }
Functions ¶
func ExpectResponse ¶
func ExpectResponse( h http.Handler, url, method string, bodySend, into, bodyExpect interface{}, code int, header http.Header, expectHeaders ...http.Header, ) error
ExpectResponse makes an HTTP Request on the given Handler, using the given URL and REST Method (i.e. PUT, POST, GET, etc.)
Multiple expected headers may be added. Each will be added into one map of expected headers using http.Header.Add; if the same header key is passed twice, the last one given will be used.
If no expected headers are passed, defaults will be selected based on expected HTTP status code: if 200,
func GetSession ¶
GetSession creates a new Session in the DB for the given User, if the user has a valid login.
func GetWSClient ¶
GetWSClient opens and returns a websocket.Conn to the given URL using the given auth token.
func MakeLogin ¶
MakeLogin creates a new auth.Login in the DB using the given name and SHA256-hashed password.
func WSAuthProtocols ¶
WSAuthProtocols returns the websocket Auth Protocol to be passed for the given Bearer Token.