handlers

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: ISC Imports: 19 Imported by: 0

Documentation

Index

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

func ArticlePath(next http.Handler) http.Handler

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)

func ProblemID

func ProblemID(next http.Handler) http.Handler

ProblemID extracts the problem ID from the request URL

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

func (env Env) Authorize(next http.Handler) http.Handler

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.

Jump to

Keyboard shortcuts

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