Documentation ¶
Index ¶
- func AddClaims(token auth.BearerToken, claims auth.Claims)
- func ArticlePath(next http.Handler) http.Handler
- func GetClaims(token auth.BearerToken) (auth.Claims, bool)
- func GetPackage() func(w http.ResponseWriter, r *http.Request)
- func ProblemID(next http.Handler) http.Handler
- type Env
- func (env Env) Authorize(next http.Handler) http.Handler
- func (env Env) GetArticle(w http.ResponseWriter, r *http.Request)
- func (env Env) Index(w http.ResponseWriter, r *http.Request)
- func (env Env) Login(w http.ResponseWriter, r *http.Request)
- func (env Env) NotFound(w http.ResponseWriter, r *http.Request)
- func (env Env) Problems(w http.ResponseWriter, r *http.Request)
- func (env Env) Token(w http.ResponseWriter, r *http.Request)
- func (env Env) UpdateDocument(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddClaims ¶
func AddClaims(token auth.BearerToken, claims auth.Claims)
AddClaims associates a bearer token with authentication claims.
func ArticlePath ¶
ArticlePath is middleware for a router to provide a clean path to an article for an HTTPHandler.
func GetClaims ¶
func GetClaims(token auth.BearerToken) (auth.Claims, bool)
GetClaims retrieves the claims associated with a bearer token.
func GetPackage ¶
func GetPackage() func(w http.ResponseWriter, r *http.Request)
Types ¶
type Env ¶ added in v0.7.0
type Env struct { Store content.Store Logger log.Logger Clock clock.Provider // TODO: split these fields into a separate environment for auth-only endpoints. // type AuthEnv struct Auth auth.Authenticator SignKey auth.SymmetricKey }
Env stores all application state that isn't request specific. All fields must be safe for concurrent use.
func (Env) Authorize ¶ added in v0.7.0
Authorize is a middleware that verifies the authorization token provided by a request, and continues to the next handler if successful.
func (Env) GetArticle ¶ added in v0.7.0
func (env Env) GetArticle(w http.ResponseWriter, r *http.Request)
GetArticle returns an HTTP handler function to respond to HTTP requests for an article. The handler will write an HTML representation of an article as a response, or a problemjson response if the article does not exist or there was a problem generating it.
func (Env) Index ¶ added in v0.7.0
func (env Env) Index(w http.ResponseWriter, r *http.Request)
Index returns an HTTP handler that responds with the site index.
func (Env) Login ¶ added in v0.7.0
func (env Env) Login(w http.ResponseWriter, r *http.Request)
Login authenticates a user and returns to them an access token and a refresh token.
func (Env) NotFound ¶ added in v0.7.0
func (env Env) NotFound(w http.ResponseWriter, r *http.Request)
NotFound is the default handler for pages that do not exist.
func (Env) Problems ¶ added in v0.7.0
func (env Env) Problems(w http.ResponseWriter, r *http.Request)
Problems is a request handler that returns an HTTP handler that responds to a request with a document describing a particular problem.
func (Env) Token ¶ added in v0.7.0
func (env Env) Token(w http.ResponseWriter, r *http.Request)
Token accepts a refresh Token from the request and sends back a new refresh and access Token.
func (Env) UpdateDocument ¶ added in v0.7.0
func (env Env) UpdateDocument(w http.ResponseWriter, r *http.Request)
UpdateDocument returns an HTTP handler function to respond to HTTP requests to update an article. The handler will update the underlying representation of an article and reply with a 200 OK, or problemjson response if the article does not exist or there was a problem updating it.