Documentation ¶
Index ¶
- Variables
- func Debug(fn func())
- func OnStartup(fn func(app *Application) error) utility.Option[Application]
- func WithAddr(network, addr string) utility.Option[Application]
- func WithBeforeStart(handler StartInterceptor) utility.Option[Application]
- func WithDefaultCodecType(typename string) utility.Option[Application]
- func WithGrpcMatcher(matcher cmux.MatchWriter) utility.Option[Application]
- func WithGrpcOpts(gopts ...utility.Option[grpcx.Server]) utility.Option[Application]
- func WithHttpErrEncoder(encoder httpx.ErrorEncoder) utility.Option[Application]
- func WithHttpOpts(hopts ...utility.Option[httpx.Server]) utility.Option[Application]
- func WithListener(listener net.Listener) utility.Option[Application]
- func WithLogger(logger *slog.Logger) utility.Option[Application]
- func WithMiddleware(middlewares ...middleware.Middleware) utility.Option[Application]
- func WithServices(services ...types.Service) utility.Option[Application]
- func WithTCPAddr(addr string) utility.Option[Application]
- type Application
- type StartInterceptor
Constants ¶
This section is empty.
Variables ¶
View Source
var IsDebug bool
Functions ¶
func OnStartup ¶
func OnStartup(fn func(app *Application) error) utility.Option[Application]
func WithAddr ¶
func WithAddr(network, addr string) utility.Option[Application]
WithAddr served http and grpc on same address
func WithBeforeStart ¶
func WithBeforeStart(handler StartInterceptor) utility.Option[Application]
func WithDefaultCodecType ¶
func WithDefaultCodecType(typename string) utility.Option[Application]
WithDefaultCodecType is http server defalt Codec type name encoding/json.Type or encoding/xml.Type or custom register Codec type
func WithGrpcMatcher ¶
func WithGrpcMatcher(matcher cmux.MatchWriter) utility.Option[Application]
WithGrpcMatcher custom grpc dispatcher
func WithGrpcOpts ¶
WithGrpcOpts accept grpc server options
func WithHttpErrEncoder ¶
func WithHttpErrEncoder(encoder httpx.ErrorEncoder) utility.Option[Application]
func WithHttpOpts ¶
func WithListener ¶
func WithListener(listener net.Listener) utility.Option[Application]
WithListener served http and grpc on same address
func WithLogger ¶
func WithLogger(logger *slog.Logger) utility.Option[Application]
func WithMiddleware ¶
func WithMiddleware(middlewares ...middleware.Middleware) utility.Option[Application]
func WithServices ¶
func WithServices(services ...types.Service) utility.Option[Application]
func WithTCPAddr ¶
func WithTCPAddr(addr string) utility.Option[Application]
WithTCPAddr is WithAddr alias but network using tcp
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func NewApp ¶
func NewApp(opts ...utility.Option[Application]) *Application
NewApp returns Application
func (*Application) Address ¶
func (app *Application) Address() net.Addr
Address returns application listen address this address is http and grpc both
func (*Application) RegisterService ¶
func (app *Application) RegisterService(services ...types.Service)
RegisterService add service to http and grpc server
func (*Application) Run ¶
func (app *Application) Run(ctx context.Context) (err error)
Run start the server until terminate
func (*Application) Shutdown ¶
func (app *Application) Shutdown()
Click to show internal directories.
Click to hide internal directories.