qrouter

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 16 Imported by: 0

README

#qrouter

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adapt

func Adapt(h http.Handler, adapters ...Adapter) http.Handler

func BindJSON added in v0.0.5

func BindJSON(w http.ResponseWriter, r *http.Request, dest interface{}) error

func DeleteCookie added in v0.0.5

func DeleteCookie(writer http.ResponseWriter, request *http.Request, name string) (string, error)

DeleteCookie receives cookie from gin.Context, deletes this cookie from gin.Context and returns its value or error.

func GetCookie added in v0.0.5

func GetCookie(writer http.ResponseWriter, request *http.Request, name string) (string, error)

GetCookie receives cookie from gin.Context or raise http.StatusForbidden error, returns cookie or error

func GetImage added in v0.0.6

func GetImage(w http.ResponseWriter, r *http.Request, i *Imager)

func ReadFile added in v0.0.5

func ReadFile(fileHeader *multipart.FileHeader, ir MultipartReader, MaxSize int64, allowedFileTypes []string) error

func RedirectJSONResponse added in v0.0.5

func RedirectJSONResponse(writer http.ResponseWriter, request *http.Request, url string, v any)

func RequestLogger added in v0.0.4

func RequestLogger(next http.Handler) http.Handler

func SetRecaptchaKey

func SetRecaptchaKey(key string)

SetRecaptchaKey is function that set recaptcha secret key

func WriteBytesResponse added in v0.0.5

func WriteBytesResponse(w http.ResponseWriter, v []byte)

func WriteJSONError added in v0.0.5

func WriteJSONError(writer http.ResponseWriter, text string, code int)

func WriteJSONResponse added in v0.0.5

func WriteJSONResponse(w http.ResponseWriter, v any)

func WriteMultipartResponse added in v0.0.5

func WriteMultipartResponse(w http.ResponseWriter, v map[string][]byte)

Types

type Adapter

type Adapter func(http.Handler) http.Handler

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

func InitApi added in v0.0.3

func InitApi(mux *http.ServeMux, path string, middleware ...Adapter) *Endpoint

func (*Endpoint) Group added in v0.0.4

func (e *Endpoint) Group(path string, middleware ...Adapter) *Endpoint

func (*Endpoint) Handle added in v0.0.4

func (e *Endpoint) Handle(h ...PathHandler)

type Imager added in v0.0.6

type Imager interface {
	SetName(name string)
	ReadRawByName(ctx context.Context) error
	GetRaw() []byte
}

type MultipartReader added in v0.0.5

type MultipartReader interface {
	ReadFromMultipart(fileHeader *multipart.FileHeader, allowedFileTypes []string) error
}

type PathHandler

type PathHandler struct {
	Path                          string
	GET, POST, PUT, PATCH, DELETE http.HandlerFunc
}

func (PathHandler) ServeHTTP

func (ph PathHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ReCaptcher

type ReCaptcher interface {
	GetReCaptcha() string
}

type RecaptchaResponse

type RecaptchaResponse struct {
	Success     bool      `json:"success"`
	Score       float64   `json:"score"`
	Action      string    `json:"action"`
	ChallengeTS time.Time `json:"challenge_ts"`
	Hostname    string    `json:"hostname"`
	ErrorCodes  []string  `json:"error-codes"`
}

RecaptchaResponse is struct that contains recaptcha validating response fields

func VerifyReCaptcha

func VerifyReCaptcha(recaptcha string) (RecaptchaResponse, error)

VerifyReCaptcha is ...

Jump to

Keyboard shortcuts

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