envelope

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteJSON

func WriteJSON(env Envelope) ([]byte, error)

Types

type Envelope

type Envelope interface {
	// Return a status code.
	//
	// This could be a HTTP status code or any other integer that makes
	// sense in this context; e.g. Unix error code.
	Status() int

	// Return HTTP headers.
	Headers() http.Header

	// Return the envelope's body.
	Body() any
}

Envelope interface.

type Error

type Error struct {
	Error   error
	Elapsed time.Duration
	// contains filtered or unexported fields
}

func NewError

func NewError(status int, err error) *Error

func (*Error) Body

func (ee *Error) Body() any

func (*Error) Headers

func (ee *Error) Headers() http.Header

func (*Error) MarshalJSON

func (ee *Error) MarshalJSON() ([]byte, error)

func (*Error) Status

func (ee *Error) Status() int

type Success

type Success struct {
	Data    any
	Count   int64
	Elapsed time.Duration
	// contains filtered or unexported fields
}

func NewSuccess

func NewSuccess(status int, data any) *Success

func (*Success) Body

func (se *Success) Body() any

func (*Success) Headers

func (se *Success) Headers() http.Header

func (*Success) MarshalJSON

func (se *Success) MarshalJSON() ([]byte, error)

func (*Success) Status

func (se *Success) Status() int

Jump to

Keyboard shortcuts

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