httpserver

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(NewHandlers, NewRouter, NewServer),
	fx.Invoke(func(lc fx.Lifecycle, shutdowner fx.Shutdowner, s *Server) {
		lc.Append(fx.Hook{
			OnStart: func(ctx context.Context) error {
				go func() {
					_ = s.Start(shutdowner)
				}()
				return nil
			},
			OnStop: func(ctx context.Context) error {
				return s.Stop(ctx)
			},
		})
	}),
)

Functions

func NewEnrichContextMiddleware

func NewEnrichContextMiddleware(logger *zap.Logger) func(next http.Handler) http.Handler

func NewLoggerMiddleware

func NewLoggerMiddleware(logger *zap.Logger) func(h http.Handler) http.Handler

func NewRecoverMiddleware

func NewRecoverMiddleware(logger *zap.Logger) func(next http.Handler) http.Handler

func NewRouter

func NewRouter(params routesParams) *mux.Router

Types

type GetInfoRespData

type GetInfoRespData struct {
	Name string `json:"name"`
}

type GetPingRespData

type GetPingRespData struct {
	Ok bool `json:"ok"`
}

type Handlers

type Handlers interface {
	Ping(rw http.ResponseWriter, r *http.Request)
	Info(rw http.ResponseWriter, r *http.Request)
}

func NewHandlers

func NewHandlers(params handlersParams) Handlers

type HandlersImpl

type HandlersImpl struct {
	Logger *zap.Logger
	Name   ecumenosfx.ServiceName
}

func (*HandlersImpl) Info

func (h *HandlersImpl) Info(rw http.ResponseWriter, r *http.Request)

func (*HandlersImpl) Ping

func (h *HandlersImpl) Ping(rw http.ResponseWriter, r *http.Request)

type Server

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

func NewServer

func NewServer(cfg *configuration.Config, logger *zap.Logger, router *mux.Router) *Server

func (*Server) Start

func (s *Server) Start(shutdowner fx.Shutdowner) error

func (*Server) Stop

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

Jump to

Keyboard shortcuts

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