Help us shape the future of Go! Take the 2026 Go Developer Survey

handlerutil

package
v2.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentActor

func CurrentActor(ctx context.Context) usertypes.Actor

func DefaultOperationSecurity

func DefaultOperationSecurity() []map[string][]string

func DownloadResponse added in v2.10.2

func DownloadResponse(reader io.ReadCloser, size int64, filename string) *huma.StreamResponse

DownloadResponse streams an attachment and closes its reader when streaming ends. A negative size means unknown and omits Content-Length.

func Error400BadRequestWithType added in v2.11.0

func Error400BadRequestWithType(detail, problemType string) huma.StatusError

Error400BadRequestWithType returns RFC 9457 problem details with a stable type.

func FeatureDisabledError added in v2.11.1

func FeatureDisabledError(id features.ID) *features.DisabledError

FeatureDisabledError identifies a disabled runtime feature in problem details.

func MapOneAPIResponse

func MapOneAPIResponse[S, D any](source S, mappingMessage func(error) string) (base.ApiResponse[D], error)

func Operation

func Operation(operationID, method, path, summary, description string, tags ...string) huma.Operation

func PaginationParams

func PaginationParams(start, limit int, sortCol, sortDir, search string) pagination.QueryParams

PaginationParams converts query parameters to pagination.QueryParams. A limit of -1 means "show all items" (no pagination).

func PaginationResponse

func PaginationResponse(p pagination.Response) base.PaginationResponse

PaginationResponse converts the pagination package's response into the API response shape.

func ParseMultipartJSONPart

func ParseMultipartJSONPart[T any](form multipart.Form, partName string) (T, error)

ParseMultipartJSONPart decodes one required JSON-valued multipart field.

func ReadWorkspaceUploads

func ReadWorkspaceUploads(form multipart.Form, maxFileSizeBytes int64) (map[int][]byte, error)

ReadWorkspaceUploads reads and validates text files from a workspace multipart request.

func RegisterSecured

func RegisterSecured[I, O any](
	api huma.API,
	op huma.Operation,
	permission string,
	handler func(context.Context, *I) (*O, error),
)

func RequireUser

func RequireUser(ctx context.Context) (*usertypes.Actor, error)

RequireUser returns the authenticated user from the request context or a 401 error.

func SessionMetaFromContext

func SessionMetaFromContext(ctx context.Context, userAgent string) auth.SessionMeta

SessionMetaFromContext builds the session metadata recorded on login.

func TranslateRemoteProxyError

func TranslateRemoteProxyError(err error) error

TranslateRemoteProxyError converts environment transport failures into Huma errors.

func WorkspaceMultipartRequestBody

func WorkspaceMultipartRequestBody(manifestDescription string) *huma.RequestBody

WorkspaceMultipartRequestBody describes the shared workspace multipart schema.

Types

type ActivityAppContext

type ActivityAppContext struct {
	// contains filtered or unexported fields
}

ActivityAppContext carries the app lifecycle context through handler registration.

func NewActivityAppContext

func NewActivityAppContext(ctx context.Context) ActivityAppContext

NewActivityAppContext wraps the app lifecycle context for handler constructors.

func (ActivityAppContext) Context

func (c ActivityAppContext) Context() context.Context

Context returns the wrapped app lifecycle context.

type Out added in v2.10.0

type Out[T any] struct {
	Body base.ApiResponse[T]
}

Out is the huma response envelope for endpoints returning base.ApiResponse[T]. It replaces the per-endpoint `type XxxOutput struct { Body base.ApiResponse[T] }` wrappers; outputs carrying extra fields (headers, status) keep their own type.

func MessageOutput added in v2.16.0

func MessageOutput(message, activityID string) *Out[base.MessageResponse]

MessageOutput is a success response carrying a message and, when an activity tracks the work, its ID.

type Page added in v2.10.0

type Page[T any] struct {
	Body base.Paginated[T]
}

Page is the huma response envelope for endpoints returning base.Paginated[T].

type RemoteJSONProxy

type RemoteJSONProxy func(context.Context, string, string, string, []byte, any) error

RemoteJSONProxy is the remote environment transport operation used by domain handlers.

func (RemoteJSONProxy) JSON added in v2.10.0

func (p RemoteJSONProxy) JSON[T any](
	ctx context.Context,
	environmentID string,
	method string,
	path string,
	requestBody any,
) (*T, error)

JSON marshals a request, invokes the environment proxy, and translates transport errors for Huma.

Jump to

Keyboard shortcuts

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