utils

package
v0.0.0-...-95589b7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowedContentTypes

func AllowedContentTypes(next http.HandlerFunc, mediaTypes ...string) http.HandlerFunc

func AllowedMethods

func AllowedMethods(next http.HandlerFunc, methods ...string) http.HandlerFunc

func DecodeCursor

func DecodeCursor(encoded string) (time.Time, uuid.UUID, error)

func EncodeCursor

func EncodeCursor(t time.Time, id uuid.UUID) string

func JsonDecodeBody

func JsonDecodeBody(r *http.Request, dst interface{}) error

func RenderResponse

func RenderResponse(r *http.Request, w http.ResponseWriter, statusCode int, res interface{})

Types

type ApiError

type ApiError struct {
	StatusCode int    `json:"-"`
	Msg        string `json:"error,omitempty"`
}

func NewBadRequest

func NewBadRequest(msg string) ApiError

func NewInternalServerError

func NewInternalServerError(msg string) ApiError

func (*ApiError) Error

func (o *ApiError) Error() string

type ContentType

type ContentType string
const (
	ContentTypeJSON ContentType = "application/json"
	ContentTypeXML  ContentType = "application/xml"
)

type XMLResponse

type XMLResponse struct {
	XMLName xml.Name    `xml:"response"`
	Data    interface{} `xml:"data,omitempty"`
	Error   string      `xml:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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