http

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadTimeout  = 5 * time.Second
	WriteTimeout = 5 * time.Second
	IdleTimeout  = 60 * time.Second
)

Variables

View Source
var ConfigDefault = Config{
	Listen:  ":3000",
	Proxies: []string{},
}
View Source
var Module = fx.Module(
	"http",
	fx.Decorate(func(log *zap.Logger) *zap.Logger {
		return log.Named("http")
	}),
	fx.Provide(
		New,
		NewServer,
	),
)

Functions

func AsApiHandler

func AsApiHandler(f any) any

func AsRootHandler

func AsRootHandler(f any) any

func New

func New(params Params) (*fiber.App, error)

func Run

func Run(params RunServerParams) error

Types

type ApiHanlder

type ApiHanlder interface {
	Register(app fiber.Router)
}

type Config

type Config struct {
	Listen  string
	Proxies []string
}

type Params

type Params struct {
	fx.In

	Config       Config
	Logger       *zap.Logger
	ApiHandlers  []ApiHanlder  `group:"api-routes"`
	RootHandlers []RootHanlder `group:"root-routes"`
	LC           fx.Lifecycle
}

type RootHanlder

type RootHanlder interface {
	Register(app *fiber.App)
}

type RunServerParams

type RunServerParams struct {
	fx.In

	Server *Server
	Logger *zap.Logger
	LC     fx.Lifecycle
}

type Server

type Server struct {
	Config Config
	App    *fiber.App
	Logger *zap.Logger
}

func NewServer

func NewServer(config Config, app *fiber.App, logger *zap.Logger) *Server

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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