response

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package response implements reflection-based net/http response encoder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncoderMiddleware

func EncoderMiddleware(handler fchi.Handler) fchi.Handler

EncoderMiddleware instruments qualifying fchi.Handler with Encoder.

func ValidatorMiddleware

func ValidatorMiddleware(factory rest.ResponseValidatorFactory) func(fchi.Handler) fchi.Handler

ValidatorMiddleware sets up response validator in suitable handlers.

Types

type Encoder

type Encoder struct {
	JSONWriter func(v interface{})
	// contains filtered or unexported fields
}

Encoder prepares and writes http response.

func (*Encoder) MakeOutput

func (h *Encoder) MakeOutput(rc *fasthttp.RequestCtx, ht rest.HandlerTrait) interface{}

MakeOutput instantiates a value for use case output port.

func (*Encoder) SetupOutput

func (h *Encoder) SetupOutput(output interface{}, ht *rest.HandlerTrait)

SetupOutput configures encoder with and instance of use case output.

func (*Encoder) WriteErrResponse

func (h *Encoder) WriteErrResponse(rc *fasthttp.RequestCtx, statusCode int, response interface{})

WriteErrResponse encodes and writes error to response.

func (*Encoder) WriteSuccessfulResponse

func (h *Encoder) WriteSuccessfulResponse(
	rc *fasthttp.RequestCtx,
	output interface{},
	ht rest.HandlerTrait,
)

WriteSuccessfulResponse encodes and writes successful output of use case interactor to http response.

Directories

Path Synopsis
Package gzip provides http compression support.
Package gzip provides http compression support.

Jump to

Keyboard shortcuts

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