Procyon|Docs
HTTP

Results

Return status, headers, and body values from HTTP handlers.

http.Result represents the response produced by a handler.

result.go
type Result interface {
	// StatusCode returns the HTTP status code.
	StatusCode() Status

	// BodyValue returns the value that should be written as the response body.
	BodyValue() any

	// Header returns response headers.
	Header() Header
}

Use http.TypedResult[T] for structured responses.

users.go
return http.TypedResult[UserDTO]{
	Body: user,
	Status: http.StatusOK,
	Headers: http.Header{
		"Cache-Control": {"no-store"},
	},
}, nil

If Status is not set, TypedResult defaults to StatusOK.

Empty responses

For handlers that do not need a serialized body, write status through the response and return no result.

health.go
func (c *HealthController) health(ctx *http.Context) error {
	ctx.Response().SetStatus(http.StatusNoContent)
	return nil
}

Use results when the framework should write a structured response. Use direct response access when the handler owns the raw response behavior.

On this page