ez

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessDeniedHandler

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

func BadRequestHandler

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

func Bool2bytes

func Bool2bytes(b bool) []byte

func DoOr401

func DoOr401[K any](w http.ResponseWriter, r *http.Request,
	handler func(w http.ResponseWriter, r *http.Request, k K),
) func(k K, err error)

func DoOr500

func DoOr500[K any](w http.ResponseWriter, r *http.Request,
	handler func(w http.ResponseWriter, r *http.Request, k K),
) func(k K, err error)

func ForbiddenHandler added in v0.0.21

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

func HexUUID

func HexUUID(u uuid.UUID) string

func InternalServerErrorHandler

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

func MapToObject

func MapToObject(m map[string]any, o any) error

func NotFoundHandler added in v0.0.21

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

func PanicIfErr

func PanicIfErr(err error)

func ParseBool

func ParseBool(b string) bool

func RandIntSeq added in v0.0.4

func RandIntSeq(n int) string

func RandSeq

func RandSeq(n int) string

func ReturnOrLog

func ReturnOrLog[K any](k K, err error) K

func ReturnOrPanic

func ReturnOrPanic[K any](k K, err error) K

func SerializeMap

func SerializeMap(m map[string]any) string

func ShardUUID

func ShardUUID(u uuid.UUID, n int) int

func StaticMsgHandler

func StaticMsgHandler(msg string) http.HandlerFunc

func StringSliceIndex

func StringSliceIndex(strs []string, s string) int

func UUIDFromString

func UUIDFromString(s string) uuid.UUID

func Us2Int

func Us2Int(us string) int64

func Us2Time

func Us2Time(us string) time.Time

func WriteBytes

func WriteBytes(w http.ResponseWriter, r *http.Request, marshal []byte)

func WriteObjectAsJSON

func WriteObjectAsJSON(w http.ResponseWriter, r *http.Request, v any)

Types

type DummyResponseWriter

type DummyResponseWriter struct {
	StatusCode int
	// contains filtered or unexported fields
}

func GetDummyResponseWriter

func GetDummyResponseWriter() *DummyResponseWriter

func (*DummyResponseWriter) Header

func (self *DummyResponseWriter) Header() http.Header

func (*DummyResponseWriter) Write

func (self *DummyResponseWriter) Write(b []byte) (int, error)

func (*DummyResponseWriter) WriteHeader

func (self *DummyResponseWriter) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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