xhttp

package
v0.0.0-...-44f2542 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultReadTimeout  = 5 * time.Second
	DefaultWriteTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func GinRequestZeroLogger

func GinRequestZeroLogger(logger *zerolog.Logger) gin.HandlerFunc

Types

type Handler

type Handler interface {
	Method() string
	Path() string
	Handle(c *gin.Context)
}

type Option

type Option func(*Server)

func WithHandlers

func WithHandlers(handlers ...Handler) Option

func WithHealthCheck

func WithHealthCheck() Option

func WithOpenTracing

func WithOpenTracing(serviceName string) Option

func WithZeroLogger

func WithZeroLogger(logger *zerolog.Logger) Option

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewGinServer

func NewGinServer(basePath string, opts ...Option) Server

NewGinServer creates a new GinServer with default healthcheck route and middlewares.

func (*Server) Handle

func (s *Server) Handle(method, path string, handler gin.HandlerFunc)

Handle adds a new route to the GinServer.

func (*Server) Run

func (s *Server) Run(port string) error

Run starts the GinServer on the specified port.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown stops the GinServer gracefully.

func (*Server) Use

func (s *Server) Use(middleware gin.HandlerFunc)

AddMiddleware adds a new middleware to the GinServer.

Jump to

Keyboard shortcuts

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