helper

package
v0.0.0-...-79ce300 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OAPIErrorHandler

func OAPIErrorHandler(w http.ResponseWriter, r *http.Request, err error)

OAPIErrorHandler renders a response when OAPI error has occurred.

func RenderError

func RenderError(err error, w http.ResponseWriter, r *http.Request) error

func RenderSuccess

func RenderSuccess(w http.ResponseWriter, r *http.Request, v Renderer)

RenderSuccess default render method for chi

Types

type ErrResponse

type ErrResponse struct {
	HTTPStatusCode int       `json:"-"`
	Status         ErrStatus `json:"status"`
}

ErrResponse is the HTTP response that reporting an error.

func (ErrResponse) Render

func (e ErrResponse) Render(w http.ResponseWriter, _ *http.Request) error

Render default render method for chi

type ErrStatus

type ErrStatus struct {
	Code    string `json:"code"`
	Message string `json:"message,omitempty"`
}

ErrStatus is the HTTP response body that reporting an error.

type Renderer

type Renderer interface {
	Render(w http.ResponseWriter, r *http.Request) error
}

Jump to

Keyboard shortcuts

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