handlerutil

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentActor

func CurrentActor(ctx context.Context) common.User

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.

func MapOneAPIResponse

func MapOneAPIResponse[S any, 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) (*common.User, 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.

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