Skip to content

Context ‚Äč

You have an access to the context inside the component. It includes request and response objects, as well as some other useful stuff like store.

go
package main

...

func Component(ctx *component.Context) component.State {
	...
	ctx.Request // http.Request
	ctx.Response // http.ResponseWriter
	ctx.Set("k", "v") // Store arbitrary data in the context
	v := ctx.Get("k").(string) // Get arbitrary data from the context
	...
}