Documentation
¶
Index ¶
- Constants
- Variables
- func NewFiberApp(name string) *fiber.App
- func RegisterHealthz(router fiber.Router)deprecated
- func RegisterProbes(router fiber.Router)
- func RegisterProbesWithState(router fiber.Router, state *profiler.State)
- type Chaindeprecated
- type Client
- type Config
- type ErrorResponse
- type HTTPClientdeprecated
- type HTTPRequest
- type HTTPResponse
- type Middleware
- type Pagination
- type Response
- type RouteChain
- type RouteMiddleware
- type Server
- type StandardClient
Constants ¶
const ( // EnvPrefix is the default environment variable prefix for HTTP server config. EnvPrefix = "APP" // DefaultShutdownTimeout is the default graceful shutdown timeout. DefaultShutdownTimeout = 10 * time.Second )
const ReadBufferSize = 16384
Variables ¶
var ErrInternal = errors.New("internal error")
var ErrorHandler = func(c fiber.Ctx, err error) error { return c.Status(http.StatusInternalServerError).JSON(Response{ Ok: false, Error: &ErrorResponse{ Message: err.Error(), Code: 0, }, }) }
Functions ¶
func NewFiberApp ¶
func RegisterHealthz
deprecated
added in
v1.1.0
func RegisterProbes ¶ added in v1.1.0
RegisterProbes adds GET /healthz, /readyz, /livez, and /startupz endpoints.
Types ¶
type Client ¶ added in v1.1.0
type Client interface {
Do(ctx context.Context, req HTTPRequest) (HTTPResponse, error)
}
Client executes HTTP requests without exposing net/http request and response values.
type Config ¶ added in v1.1.0
type Config struct {
Address string `env:"_ADDR" envDefault:":8080"`
Host string `env:"_HOST" envDefault:"localhost:8080"`
Scheme string `env:"_SCHEME" envDefault:"http"`
Name string `env:"_NAME" envDefault:"server"`
MonitorAddr string `env:"_MONITOR_ADDR" envDefault:":8011"`
ShutdownTimeout time.Duration `env:"_SHUTDOWN_TIMEOUT" envDefault:"10s"`
ShutdownListener *oslistener.SignalListener `env:"-"`
ProfilerState *profiler.State `env:"-"`
}
Config holds HTTP server configuration.
func GetEnvConfig ¶ added in v1.1.0
GetEnvConfig reads HTTP server configuration from environment variables.
type ErrorResponse ¶
func (ErrorResponse) MarshalEasyJSON ¶
func (v ErrorResponse) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ErrorResponse) MarshalJSON ¶
func (v ErrorResponse) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ErrorResponse) UnmarshalEasyJSON ¶
func (v *ErrorResponse) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ErrorResponse) UnmarshalJSON ¶
func (v *ErrorResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type HTTPRequest ¶ added in v1.1.0
HTTPRequest is the core-owned HTTP request shape for outbound web calls.
type HTTPResponse ¶ added in v1.1.0
HTTPResponse is the core-owned HTTP response shape for outbound web calls.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware contains methods to call before handle request
func NewMiddleware ¶
func NewMiddleware(c ...Chain) *Middleware
NewMiddleware return new natsmiddleware
func (*Middleware) AddChain ¶
func (m *Middleware) AddChain(c Chain)
AddChain add natsmiddleware to execute
func (*Middleware) Merge ¶
func (m *Middleware) Merge(middlewares ...*Middleware)
Merge merge logmiddlewares into current
type Pagination ¶
type Pagination struct {
Total int `json:"total"`
Page int `json:"page"`
Pages int `json:"pages"`
PerPage int `json:"per_page"`
}
func (Pagination) MarshalEasyJSON ¶
func (v Pagination) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (Pagination) MarshalJSON ¶
func (v Pagination) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*Pagination) UnmarshalEasyJSON ¶
func (v *Pagination) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Pagination) UnmarshalJSON ¶
func (v *Pagination) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type Response ¶
type Response struct {
Data interface{} `json:"data,omitempty"`
Error *ErrorResponse `json:"error,omitempty"`
Pagination *Pagination `json:"pagination,omitempty"`
Ok bool `json:"ok"`
}
func GetResponseWithError ¶
func GetSuccessResponse ¶
func GetSuccessResponse(data interface{}) *Response
func GetSuccessResponseList ¶
func (Response) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Response) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Response) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Response) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type RouteChain ¶ added in v1.1.0
type RouteChain func(h RouteHandler) RouteHandler
RouteChain composes core-owned route handlers.
type RouteMiddleware ¶ added in v1.1.0
type RouteMiddleware struct {
// contains filtered or unexported fields
}
RouteMiddleware contains core-owned route middleware chains.
func NewRouteMiddleware ¶ added in v1.1.0
func NewRouteMiddleware(chains ...RouteChain) *RouteMiddleware
NewRouteMiddleware returns middleware for core-owned route handlers.
func (*RouteMiddleware) AddChain ¶ added in v1.1.0
func (m *RouteMiddleware) AddChain(chain RouteChain)
AddChain appends a core-owned route middleware chain.
func (*RouteMiddleware) Copy ¶ added in v1.1.0
func (m *RouteMiddleware) Copy() *RouteMiddleware
Copy returns a copy of the route middleware chain.
func (*RouteMiddleware) Merge ¶ added in v1.1.0
func (m *RouteMiddleware) Merge(middlewares ...*RouteMiddleware)
Merge appends chains from other route middleware values.
func (*RouteMiddleware) Then ¶ added in v1.1.0
func (m *RouteMiddleware) Then(handler RouteHandler) RouteHandler
Then wraps the route handler with all configured route chains.
type Server ¶ added in v1.1.0
Server wraps fiber.App with graceful shutdown support.
type StandardClient ¶ added in v1.1.0
type StandardClient struct {
// contains filtered or unexported fields
}
StandardClient adapts a legacy HTTPClient to the core-owned Client contract.
func NewStandardClient ¶ added in v1.1.0
func NewStandardClient(client HTTPClient) *StandardClient
NewStandardClient wraps a net/http-compatible client with the core-owned Client contract.
func (*StandardClient) Do ¶ added in v1.1.0
func (c *StandardClient) Do(ctx context.Context, req HTTPRequest) (HTTPResponse, error)
Do executes a request and returns a core-owned response.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock_webserver is a generated GoMock package.
|
Package mock_webserver is a generated GoMock package. |