router

package
v0.0.0-...-1ef1c0e Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

* Copyright (c) 2023 * All rights reserved.

* Copyright (c) 2023 * All rights reserved.

Index

Constants

This section is empty.

Variables

View Source
var Header = headerBinding{}
View Source
var Query = queryBinding{}

Functions

func BindModel

func BindModel(req any) gin.HandlerFunc

func CookiesParser

func CookiesParser(c *gin.Context, model any) error

Types

type ContentTypeType

type ContentTypeType string
var (
	ContentTypeRequest  ContentTypeType = "request"
	ContentTypeResponse ContentTypeType = "response"
)

type ErrorHandlerFunc

type ErrorHandlerFunc func(ctx *gin.Context, err error, status int)

type Model

type Model any

type Option

type Option func(router *Router)

func ContentType

func ContentType(contentType string, contentTypeType ContentTypeType) Option

ContentType Set request contentType

func Deprecated

func Deprecated() Option

Deprecated mark api is deprecated

func Description

func Description(description string) Option

func Exclude

func Exclude() Option

Exclude exclude in docs

func Handlers

func Handlers(handlers ...gin.HandlerFunc) Option

func OperationID

func OperationID(ID string) Option

func Responses

func Responses(response Response) Option

func Security

func Security(securities ...security.ISecurity) Option

func Summary

func Summary(summary string) Option

func Tags

func Tags(tags ...string) Option

type Response

type Response map[string]ResponseItem

type ResponseItem

type ResponseItem struct {
	Description string
	Model       any
	Headers     openapi3.Headers
}

type Router

type Router struct {
	Handlers            *list.List
	Path                string
	Method              string
	Summary             string
	Description         string
	Deprecated          bool
	RequestContentType  string
	ResponseContentType string
	Tags                []string
	API                 gin.HandlerFunc
	Model               Model
	OperationID         string
	Exclude             bool
	Securities          []security.ISecurity
	Response            Response
}

func New

func New[T Model, F func(c *gin.Context, req T)](f F, options ...Option) *Router

func NewX

func NewX(f gin.HandlerFunc, options ...Option) *Router

func (*Router) GetHandlers

func (router *Router) GetHandlers() []gin.HandlerFunc

func (*Router) WithContentType

func (router *Router) WithContentType(contentType string, contentTypeType ContentTypeType) *Router

func (*Router) WithDeprecated

func (router *Router) WithDeprecated() *Router

func (*Router) WithDescription

func (router *Router) WithDescription(description string) *Router

func (*Router) WithExclude

func (router *Router) WithExclude() *Router

func (*Router) WithHandlers

func (router *Router) WithHandlers(handlers ...gin.HandlerFunc) *Router

func (*Router) WithOperationID

func (router *Router) WithOperationID(ID string) *Router

func (*Router) WithResponses

func (router *Router) WithResponses(response Response) *Router

func (*Router) WithSecurity

func (router *Router) WithSecurity(securities ...security.ISecurity) *Router

func (*Router) WithSummary

func (router *Router) WithSummary(summary string) *Router

func (*Router) WithTags

func (router *Router) WithTags(tags ...string) *Router

Jump to

Keyboard shortcuts

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