transport

package
v0.0.0-...-5597880 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accepted

type Accepted struct{}

func (*Accepted) StatusCode

func (a *Accepted) StatusCode() int

type ByteWriter

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

ByteWriter provides a convenience struct for returning a byte slice as a response

func NewByteWriter

func NewByteWriter(typ, encoding string, data []byte) *ByteWriter

func (*ByteWriter) Encode

func (b *ByteWriter) Encode(w http.ResponseWriter) error

type DecoderFunc

type DecoderFunc[In any] func(r *http.Request) (In, error)

DecoderFunc is a function that decodes a request into a struct

type Empty

type Empty struct{}

Empty provides a convenience struct for returning an empty response

func (*Empty) StatusCode

func (e *Empty) StatusCode() int

type Encoder

type Encoder interface {
	Encode(w http.ResponseWriter) error
}

type Redirect

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

func NewRedirect

func NewRedirect(newURL string, r *http.Request) *Redirect

func (*Redirect) Encode

func (r *Redirect) Encode(w http.ResponseWriter) error

type StatusCoder

type StatusCoder interface {
	StatusCode() int
}

type TargetFunc

type TargetFunc[In any, Out any] func(context.Context, *http.Request, In) (Out, error)

TargetFunc is a function that handles the request and returns a response, ideally we shouldn't have to use the http.Request, but sometimes we need it to fetch query parameters, headers, or similar

type Transport

type Transport[In any, Out any] struct {
	// contains filtered or unexported fields
}

func For

func For[In any, Out any](target TargetFunc[In, Out]) *Transport[In, Out]

func (*Transport[In, Out]) Build

func (h *Transport[In, Out]) Build(logger zerolog.Logger) http.HandlerFunc

func (*Transport[In, Out]) RequestFromJSON

func (h *Transport[In, Out]) RequestFromJSON() *Transport[In, Out]

Jump to

Keyboard shortcuts

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