v1

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package v1 provides generic HTTP transport layer utilities.

Package v1 provides generic HTTP transport layer utilities.

Package v1 provides generic HTTP transport layer utilities. It defines Decoder, Encoder, and Handler interfaces with generic type constraints for building type-safe HTTP handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder[HTTPReq, DomainReq any] func(ctx context.Context, r HTTPReq) (DomainReq, error)

Decoder defines the request decoder interface. It converts an HTTP request type to a domain request type. HTTPReq: HTTP request type DomainReq: domain request type

type Encoder

type Encoder[DomainResp, HTTPResp any] func(ctx context.Context, r DomainResp) (HTTPResp, error)

Encoder defines the response encoder interface. It converts a domain response type to an HTTP response type. DomainResp: domain response type HTTPResp: HTTP response type

type Handler

type Handler[HTTPReq, HTTPResp any] interface {
	ServeHTTP(c *gin.Context)
}

Handler defines the HTTP handler interface with generic type constraints. HTTPReq is the HTTP request type, HTTPResp is the HTTP response type.

func NewHandler

func NewHandler[HTTPReq, DomainReq, DomainResp, HTTPResp any](
	ep epv1.Endpoint[DomainReq, DomainResp],
	decoder Decoder[HTTPReq, DomainReq],
	encoder Encoder[DomainResp, HTTPResp],
) Handler[HTTPReq, HTTPResp]

NewHandler creates a new HTTP handler with the given endpoint, decoder, and encoder. The handler provides type-safe conversion between HTTP types and domain types.

Jump to

Keyboard shortcuts

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