middleware

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIMEJSON              = "application/json"
	MIMEHTML              = "text/html"
	MIMEXML               = "application/xml"
	MIMEXML2              = "text/xml"
	MIMEPlain             = "text/plain"
	MIMEPOSTForm          = "application/x-www-form-urlencoded"
	MIMEMultipartPOSTForm = "multipart/form-data"
	MIMEPROTOBUF          = "application/x-protobuf"
	MIMEYAML              = "application/x-yaml"
)

Content-Type MIME of the most common data formats.

Variables

View Source
var Translang = Trans{
	Lang:                        ja.New(),
	RegisterDefaultTranslations: jaTranslations.RegisterDefaultTranslations,
}

Functions

func CORS

func CORS(ctx interfaces.Context)

CORS CORSの適応

func ChangeTranslate

func ChangeTranslate()

func Logger

func Logger(ctx interfaces.Context)

Logger ログ出力

func NewrelicMiddleware

func NewrelicMiddleware() interfaces.BdxHandlerFunc

NewrelicMiddleware newrelic monitoringツールを使用する際のミドルウェア

func RoleCheck added in v0.0.3

func RoleCheck(headerKey string, roles []string) func(c interfaces.Context)

RoleCheck ロール確認ミドルウェア

func Validator

func Validator(x interface{}) interfaces.BdxHandlerFunc

Validator は`Request.Body`にセットされている`JSON文字列`を`x`の引数の型に変換し、

`go-playground.Validator`でバリデーション処理を行うミドルウェア

エラーが発生した際はエラーレスポンスへ変換して後続のミドルウェア、ハンドルを実行しない

Types

type MIMEType

type MIMEType int
const (
	JSON MIMEType = iota
	XML
	YAML
	HTML
)

type Trans

type Trans struct {
	Lang                        locales.Translator
	RegisterDefaultTranslations func(*validator.Validate, ut.Translator) error
}

Jump to

Keyboard shortcuts

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