Documentation
¶
Index ¶
Constants ¶
const (
// RuntimeIDHeaderKey denotes the header name / key that identifies the server runtime ID
RuntimeIDHeaderKey = "X-GOPROBE-RUNTIME-ID"
)
Variables ¶
This section is empty.
Functions ¶
func GenerateSpec ¶
func GenerateSpec(ctx context.Context, path string, ow OpenAPISpecWriter) error
GenerateSpec writes the OpenAPI spec to a file
Types ¶
type DefaultServer ¶
type DefaultServer struct {
// contains filtered or unexported fields
}
DefaultServer is the default API server, allowing middlewares and settings to be re-used across binaries serving an API
func NewDefault ¶
func NewDefault(serviceName, addr string, opts ...Option) *DefaultServer
NewDefault creates a new API server
func (*DefaultServer) API ¶
func (server *DefaultServer) API() huma.API
API returns the huma API server which is used to register and document endpoints
func (*DefaultServer) QueryRateLimiter ¶
func (server *DefaultServer) QueryRateLimiter() (int, *rate.Limiter, bool)
QueryRateLimiter returns the maximum number of concurrent queries and the global rate limiter, if enabled (if not it return nil and false)
func (*DefaultServer) Serve ¶
func (server *DefaultServer) Serve() error
Serve starts the API server after adding additional (optional) routes
func (*DefaultServer) Shutdown ¶
func (server *DefaultServer) Shutdown(ctx context.Context) error
Shutdown shuts down the API server
func (*DefaultServer) WriteOpenAPISpec ¶
func (server *DefaultServer) WriteOpenAPISpec(w io.Writer) error
WriteOpenAPISpec writes the full OpenAPI spec to the writer w. It implements the OpenAPISpecWriter interface
type OpenAPISpecWriter ¶
OpenAPISpecWriter can be implemented by any server able to produce an OpenAPI spec from its registered routes
type Option ¶
type Option func(*DefaultServer)
Option denotes a functional option fo a default server instance
func WithDebugMode ¶
WithDebugMode runs the gin server in debug mode (e.g. not setting the release mode)
func WithMetrics ¶
WithMetrics enables prometheus metrics endpoints. The request duration can be provided if they should differ from the default duration buckets
func WithNoRecursionDetection ¶
func WithNoRecursionDetection() Option
WithNoRecursionDetection disables the query recursion detection
func WithProfiling ¶
WithProfiling enables runtime profiling endpoints
func WithQueryRateLimit ¶
WithQueryRateLimit enables a global rate limit for query calls