http

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(newHttp),
	fx.Invoke(runHttpServer),
	fx.Provide(NewRouter),
	fx.Provide(NewSwaggerHandler),
)

Functions

func AsControllerRoute

func AsControllerRoute(controller any) any

func AsHandlerRoute

func AsHandlerRoute(handler any) any

Types

type Config

type Config struct {
	ListenAddr string `env:"LISTEN_ADDR, default=:8080"`
}

type ControllerRoute

type ControllerRoute interface {
	RegisterControllerRoutes(rg *gin.RouterGroup)
	RoutePattern() string
}

type HandlerRoute

type HandlerRoute interface {
	HttpHandler() http.Handler
	RoutePattern() string
}

type Params

type Params struct {
	fx.In
	Logger           *zap.SugaredLogger `optional:"true"`
	ControllerRoutes []ControllerRoute  `group:"controllerRoutes"`
	HandlerRoutes    []HandlerRoute     `group:"handlerRoutes"`
	SwaggerHandler   *SwaggerHandler
}

type Result

type Result struct {
	fx.Out
	Http *gin.Engine
}

func NewRouter

func NewRouter(p Params) Result

func (*Result) GetHttpRouter

func (r *Result) GetHttpRouter() *gin.Engine

type SwaggerHandler

type SwaggerHandler struct{}

func NewSwaggerHandler

func NewSwaggerHandler() *SwaggerHandler

func (*SwaggerHandler) GinHandler

func (h *SwaggerHandler) GinHandler() gin.HandlerFunc

func (*SwaggerHandler) RoutePattern

func (h *SwaggerHandler) RoutePattern() string

Jump to

Keyboard shortcuts

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