HTTPContext
Request
Read path values, query values, cookies, body, and native request data.
ServerRequest wraps the incoming HTTP request and provides convenience helpers.
func (c *UserController) search(ctx *http.Context) (http.Result, error) {
id := ctx.Request().PathValue("id")
query, _ := ctx.Request().Query("q")
session, hasSession := ctx.Request().Cookie("session")
results, err := c.service.Search(ctx, SearchRequest{
ID: id,
Query: query,
HasSession: hasSession,
Session: session,
})
if err != nil {
return nil, err
}
return http.TypedResult[[]UserDTO]{Body: results}, nil
}Use request helpers for direct HTTP details. Prefer typed endpoint context when the handler input should be described by a struct.
