Documentation
¶
Index ¶
- Constants
- func HTTPError(c echo.Context, err error, statusCode int)
- func UnescapedJSON(c echo.Context, code int, i interface{}) error
- type Config
- type CustomValidator
- type Option
- func WithEnableSwaggerUI(enableSwaggerUI bool) Option
- func WithLogLevel(logLevel string) Option
- func WithMaxBytesToReadInBody(size string) Option
- func WithProtocol(protocol string) Option
- func WithReadHeaderTimeout(t time.Duration) Option
- func WithReadTimeout(t time.Duration) Option
- func WithRequestHandlerTimeout(t time.Duration) Option
- func WithSkipTimeoutPaths(paths []string) Option
- func WithThrottleLimit(limit int) Option
- func WithWriteTimeout(t time.Duration) Option
- type Server
- type ServerParams
Constants ¶
View Source
const TimeoutMessage = "Server Timeout!"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶ added in v1.0.4
type Config struct {
// These are TCP connection deadlines and not HTTP timeouts. They don't control the time it takes for our handlers
// to complete. Deadlines operate on the connection, so our server will fail to return a result only after
// the handlers try to access connection properties
// ReadHeaderTimeout is the amount of time allowed to read request headers
ReadHeaderTimeout time.Duration
// ReadTimeout is the maximum duration for reading the entire request, including the body
ReadTimeout time.Duration
// WriteTimeout is the maximum duration before timing out writes of the response.
// It doesn't cancel the context and doesn't stop handlers from running even after failing the request.
// It is for added safety and should be a bit longer than the request handler timeout for better error handling.
WriteTimeout time.Duration
// This represents maximum duration for handlers to complete, or else fail the request with 503 error code.
RequestHandlerTimeout time.Duration
// SkippedTimeoutPaths is a list of paths that should not be subject to the request handler timeout.
SkippedTimeoutPaths []string
// MaxBytesToReadInBody is used by safeHandlerFuncWrapper as the max size of body
MaxBytesToReadInBody string
// ThrottleLimit is the maximum number of requests per second
ThrottleLimit int
// Protocol
Protocol string
// LogLevel is the minimum log level to log requests
LogLevel string
// EnableSwaggerUI is a flag to enable swagger UI
EnableSwaggerUI bool
}
func DefaultConfig ¶ added in v1.0.4
func DefaultConfig() Config
DefaultConfig returns the default configuration for the public API server.
type CustomValidator ¶ added in v1.0.4
type CustomValidator struct {
// contains filtered or unexported fields
}
CustomValidator is a custom validator for echo framework that does the following: - Uses go-playground/validator for validation if validator tags are present - Uses Validate() method if the struct implements validatable interface
func NewCustomValidator ¶ added in v1.0.4
func NewCustomValidator() *CustomValidator
func (*CustomValidator) Validate ¶ added in v1.0.4
func (cv *CustomValidator) Validate(i interface{}) error
type Option ¶ added in v1.0.4
type Option func(*Config)
func WithEnableSwaggerUI ¶ added in v1.0.4
func WithLogLevel ¶ added in v1.0.4
func WithMaxBytesToReadInBody ¶ added in v1.0.4
func WithProtocol ¶ added in v1.0.4
func WithReadHeaderTimeout ¶ added in v1.0.4
func WithReadTimeout ¶ added in v1.0.4
func WithRequestHandlerTimeout ¶ added in v1.0.4
func WithSkipTimeoutPaths ¶ added in v1.0.4
func WithThrottleLimit ¶ added in v1.0.4
func WithWriteTimeout ¶ added in v1.0.4
type Server ¶ added in v1.0.4
type Server struct {
Router *echo.Echo
Address string
Port uint16
TLSCertificateFile string
TLSKeyFile string
// contains filtered or unexported fields
}
Server configures a node's public REST API.
func NewAPIServer ¶
func NewAPIServer(params ServerParams) (*Server, error)
func (*Server) GetURI ¶ added in v1.0.4
GetURI returns the HTTP URI that the server is listening on.
func (*Server) ListenAndServe ¶ added in v1.0.4
@title Bacalhau API @description This page is the reference of the Bacalhau REST API. Project docs are available at https://docs.bacalhau.org/. Find more information about Bacalhau at https://github.com/bacalhau-project/bacalhau. @contact.name Bacalhau Team @contact.url https://github.com/bacalhau-project/bacalhau @contact.email team@bacalhau.org @license.name Apache 2.0 @license.url https://github.com/bacalhau-project/bacalhau/blob/main/LICENSE @host bootstrap.production.bacalhau.org:1234 @BasePath / @schemes http
ListenAndServe listens for and serves HTTP requests against the API server.
Click to show internal directories.
Click to hide internal directories.