httputil

package
v0.0.1-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authorize

func Authorize(w http.ResponseWriter, r *http.Request, jwtSigningKey, expectedAPIKey string, next http.Handler)

Authorize validates the JWT, or API key if caller is a Kenza service, and makes claims available for downstream handlers.

func JWT

func JWT(username string, userID int64, accounts map[int64]string, jwtKey string) (token string, err error)

JWT signs a new JWT with the parameters as claims (plus some standard claims).

func Log

func Log(next http.Handler) http.Handler

Log logs the incoming request and calls `ServeHTTP` on the next handler.

func Param

func Param(r *http.Request, name string) string

Param returns the string value (empty if no parameter with that name exists) of the requested path parameter.

func UserID

func UserID(r *http.Request) int64

UserID returns the authenticated user's ID for the request. MUST be called after the `Authorize` handler, panics otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL