httputil

package
v0.0.0-...-247c3a5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorBadData   errorType = "bad_data"
	ErrorNotFound  errorType = "not_found"
	ErrorBadAuth   errorType = "bad_auth"
	ErrorForbidden errorType = "no_permission"
	ErrorInternal  errorType = "internal"
)
View Source
const (
	ResponseTypeJson responseType = "json"
	ResponseTypeHtml responseType = "html"
	ResponseTypeJpeg responseType = "jpeg"
)

Variables

This section is empty.

Functions

func ResponseWrapper

func ResponseWrapper(f HttpUseCase) http.HandlerFunc

Types

type HandleError

type HandleError struct {
	Type     errorType `json:"type"`
	ErrorKey string    `json:"error_key"`
	Message  string    `json:"message"`
	Err      error     `json:"-"`
}

func (*HandleError) GetHttpStatus

func (h *HandleError) GetHttpStatus() int

func (*HandleError) JsonEncode

func (h *HandleError) JsonEncode() []byte

type HandleResult

type HandleResult struct {
	Payload interface{}
	Type    responseType
	Error   *HandleError
}

func (HandleResult) HasError

func (h HandleResult) HasError() bool

type HttpUseCase

type HttpUseCase func(r *http.Request) HandleResult

Jump to

Keyboard shortcuts

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