utils

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

utils

some usefull utils for work

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowMethods

func AllowMethods(methods []string) func(http.Handler) http.Handler

AllowMethods is http server middleware to limit http request methods

func FileUploadHandler

func FileUploadHandler(cfg FileUploadConfig) http.Handler

FileUploadHandler is http handler to handler file upload

func GenerateUUID

func GenerateUUID() string

GenerateUUID generate a version 4 UUID string

func GetI18nPrinter

func GetI18nPrinter(r *http.Request) *message.Printer

GetI18nPrinter return a message.printer according the request header user can override default Accept-Language header by add the language header

func LoggingHandler

func LoggingHandler(next http.Handler) http.Handler

LoggingHandler is http server middleware to log http request

func RecoveryHandler

func RecoveryHandler(next http.Handler) http.Handler

RecoveryHandler is http server middleware to recover from panic and log the call stack

Types

type FileUploadConfig

type FileUploadConfig struct {
	AllowExts   []string // allowed file to upload, example  .jpg, .png
	StoragePath string   // path to store the uploaded file

	// ResponseFunc a function to write the response to user
	ResponseFunc func(w http.ResponseWriter, filenames []string, err error)
}

FileUploadConfig config the file upload handler

Jump to

Keyboard shortcuts

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