render

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidationErrCode     = 101
	InternalServerErrCode = 500
)
View Source
const (
	UnknownErrCode = 400
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONAPI

type JSONAPI struct {
	Data  any
	Meta  *jsonapi.Meta  `json:"-"`
	Links *jsonapi.Links `json:"-"`
}

func (JSONAPI) Render

func (j JSONAPI) Render(w http.ResponseWriter) error

func (JSONAPI) WriteContentType

func (j JSONAPI) WriteContentType(w http.ResponseWriter)

type JSONAPIErrors

type JSONAPIErrors struct {
	Errors []*jsonapi.ErrorObject
	// contains filtered or unexported fields
}

func NewJSONAPIErrors

func NewJSONAPIErrors() *JSONAPIErrors

func (*JSONAPIErrors) AddError

func (e *JSONAPIErrors) AddError(err error) *JSONAPIErrors

func (*JSONAPIErrors) AddErrors

func (e *JSONAPIErrors) AddErrors(errs []error) *JSONAPIErrors

func (*JSONAPIErrors) GetHTTPStatus

func (e *JSONAPIErrors) GetHTTPStatus() int

func (*JSONAPIErrors) Render

func (e *JSONAPIErrors) Render(w http.ResponseWriter) error

func (*JSONAPIErrors) WriteContentType

func (e *JSONAPIErrors) WriteContentType(w http.ResponseWriter)

type Response

type Response struct {
	Status    string `json:"status"`
	ErrorCode int    `json:"error_code"`
	Message   string `json:"message"`
	Data      any    `json:"data,omitempty"`
}

func NewResponse

func NewResponse(data any, errorCode int, status, message string) Response

func NewResponseWithError

func NewResponseWithError(err error) Response

func NewSuccessResponse

func NewSuccessResponse(data any, message string) Response

func (Response) Render

func (r Response) Render(w http.ResponseWriter) (err error)

func (Response) WriteContentType

func (r Response) WriteContentType(w http.ResponseWriter)

Jump to

Keyboard shortcuts

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