Documentation ¶
Overview ¶
Package gin implements a HTTP web framework called gin.
Index ¶
- Constants
- func SetMode(value string)
- type Context
- type Engine
- type H
- type HandlerFunc
- type Option
- func WithMeterProvider(mp metric.MeterProvider) Option
- func WithOperationName(name string) Option
- func WithPropagators(ps propagation.TextMapPropagator) Option
- func WithServerName(name string) Option
- func WithSpanNameFormatter(f SpanNameFormatter) Option
- func WithTracerProvider(tp trace.TracerProvider) Option
- type OptionFunc
- type SpanNameFormatter
Constants ¶
const ( // DebugMode indicates gin mode is debug. DebugMode = gin.DebugMode // ReleaseMode indicates gin mode is release. ReleaseMode = gin.ReleaseMode // TestMode indicates gin mode is test. TestMode = gin.TestMode )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
Context is the most important part of gin. It allows us to pass variables between middleware, manage the flow, validate the JSON of a request and render a JSON response for example.
type Engine ¶
Engine is the framework's instance, it contains the muxer, middleware and configuration settings. Create an instance of Engine, by using New() or Default()
type HandlerFunc ¶
type HandlerFunc = gin.HandlerFunc
HandlerFunc defines the handler used by gin middleware as return value.
func Logger ¶
func Logger() HandlerFunc
Logger instances a Logger middleware that will write the logs to gin.DefaultWriter. By default gin.DefaultWriter = os.Stdout.
func OTel ¶
func OTel(opts ...Option) (HandlerFunc, error)
OTel returns middleware that provides OpenTelemetry tracing and metrics to a gin web app.
func Recovery ¶
func Recovery() HandlerFunc
Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
type Option ¶
type Option interface {
Apply(*config)
}
Option applies a configuration to the given config.
func WithMeterProvider ¶
func WithMeterProvider(mp metric.MeterProvider) Option
WithMeterProvider specifies a meter provider to use for creating a meter. If none is specified, the global provider is used.
func WithOperationName ¶
WithOperationName specifies a operation name. If none is specified, the default operation name is used.
func WithPropagators ¶
func WithPropagators(ps propagation.TextMapPropagator) Option
WithPropagators specifies a propagators. If none is specified, the global propagator is used.
func WithServerName ¶
WithServerName specifies a server name. If none is specified, the default server name is used.
func WithSpanNameFormatter ¶
func WithSpanNameFormatter(f SpanNameFormatter) Option
WithSpanNameFormatter specifies a formatter to used to format span names. If none is specified, the default SpanNameFormatter is used.
func WithTracerProvider ¶
func WithTracerProvider(tp trace.TracerProvider) Option
WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.
type OptionFunc ¶
type OptionFunc func(c *config)
OptionFunc provides a convenience wrapper for simple Options that can be represented as functions.
func (OptionFunc) Apply ¶
func (o OptionFunc) Apply(c *config)
Apply will apply the option to the config.