httpserver

package
v0.0.0-...-56ce8b6 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: Apache-2.0 Imports: 12 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 WithCORS

func WithCORS() Option

func WithHandlers

func WithHandlers(handlers ...Handler) Option

func WithHealthCheck

func WithHealthCheck() Option

func WithOpenTracing

func WithOpenTracing(serviceName string) Option

func WithSwaggerDocs

func WithSwaggerDocs(url 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, port 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(ctx context.Context) error

Run starts the GinServer on the specified port.

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