ginkit

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortJSON

func AbortJSON(ctx *gin.Context, statusCode int, verdict string, message string, data interface{})

AbortJSON abort with JSON

func Authenticate

func Authenticate(verifier auth.Verifier) gin.HandlerFunc

Authenticate authenticate user

func MaxBody

func MaxBody(maxBytes int64) gin.HandlerFunc

MaxBody checks maxbody payload

func Recovery

func Recovery() gin.HandlerFunc

Recovery returns a middleware for a given writer that recovers from any panics and calls the provided handle func to handle it

func RegisterTagNameFunc

func RegisterTagNameFunc() bool

RegisterTagNameFunc registers tags function

func RequestIDMiddleware

func RequestIDMiddleware() gin.HandlerFunc

RequestIDMiddleware adds X-Request-ID value to request, response and save to context variable

func RequestTimeMiddleware

func RequestTimeMiddleware() gin.HandlerFunc

RequestTimeMiddleware logs request time

func SendError

func SendError(ctx *gin.Context, _ error)

SendError sends error

func SendInvalidParameters

func SendInvalidParameters(ctx *gin.Context, names []string)

SendInvalidParameters sends invalid parameters

func SendJSON

func SendJSON(ctx *gin.Context, statusCode int, verdict string, message string, data interface{})

SendJSON sends JSON

func SendSuccess

func SendSuccess(ctx *gin.Context, message string, data interface{})

SendSuccess sends success response

func SendValidationError

func SendValidationError(ctx *gin.Context, err error)

SendValidationError sends validation error response to client

func Setup

func Setup()

Setup one time setup. Must be called at the startup

func Start

func Start(ctx context.Context, engine *gin.Engine, address string, options ...OptionFunc) error

Start starts server

func TracingMiddleware

func TracingMiddleware(service string, opts ...otelgin.Option) gin.HandlerFunc

TracingMiddleware adds tracing into gin's middlewares by using otelgin.Middleware function

Types

type Field

type Field struct {
	Name    string `json:"name"`
	Message string `json:"message"`
}

func GetUnmarshalErrorParameters

func GetUnmarshalErrorParameters(err error) (*Field, bool)

GetUnmarshalErrorParameters returns list of invalid parameters

type Fields

type Fields []*Field

func GetInvalidParameters

func GetInvalidParameters(err error) Fields

GetInvalidParameters gets list of invalid parameters

func (Fields) GetNames

func (f Fields) GetNames() []string

func (Fields) ToKeyValues

func (f Fields) ToKeyValues() types.Map

type OptionFunc

type OptionFunc func(s *http.Server)

OptionFunc defines server option

Jump to

Keyboard shortcuts

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