Documentation ¶
Index ¶
- type API
- type Option
- func WithAPIDefaults() Option
- func WithAPIKeyAuthenticator(f func(string, string, security.TokenAuthentication) runtime.Authenticator) Option
- func WithBasicAuthenticator(f func(security.UserPassAuthentication) runtime.Authenticator) Option
- func WithBearerAuthenticator(f func(string, security.ScopedTokenAuthentication) runtime.Authenticator) Option
- func WithBinProducer(p runtime.Producer) Option
- func WithCleanupTimeout(t time.Duration) Option
- func WithCommandLineOptionsGroups(g []swag.CommandLineOptionsGroup) Option
- func WithConfiguredAPI() Option
- func WithEnabledListeners(listeners []string) Option
- func WithGracefulTimeout(t time.Duration) Option
- func WithHTMLProducer(p runtime.Producer) Option
- func WithHost(host string) Option
- func WithJSONConsumer(c runtime.Consumer) Option
- func WithJSONProducer(p runtime.Producer) Option
- func WithKeepAlive(t time.Duration) Option
- func WithListenLimit(limit int) Option
- func WithLogger(f func(string, ...interface{})) Option
- func WithMaxHeaderSize(size int) Option
- func WithPort(port int) Option
- func WithPreServerShutdown(f func()) Option
- func WithReadTimeout(t time.Duration) Option
- func WithServeError(f func(http.ResponseWriter, *http.Request, error)) Option
- func WithServerDefaults() Option
- func WithServerShutdown(f func()) Option
- func WithSocketPath(path string) Option
- func WithTLSCACertificate(cert string) Option
- func WithTLSCertificate(cert string) Option
- func WithTLSCertificateKey(cert string) Option
- func WithTLSHost(host string) Option
- func WithTLSKeepAlive(t time.Duration) Option
- func WithTLSListenLimit(limit int) Option
- func WithTLSPort(port int) Option
- func WithTLSReadTimeout(t time.Duration) Option
- func WithTLSWriteTimeout(t time.Duration) Option
- func WithWriteTimeout(t time.Duration) Option
- type Plug
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { SetDefaultProduces(mediaType string) SetDefaultConsumes(mediaType string) SetSpec(spec *loads.Document) DefaultProduces() string DefaultConsumes() string Formats() strfmt.Registry RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) Validate() error ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator Authorizer() runtime.Authorizer ConsumersFor(mediaTypes []string) map[string]runtime.Consumer ProducersFor(mediaTypes []string) map[string]runtime.Producer HandlerFor(method, path string) (http.Handler, bool) Context() *middleware.Context Serve(builder middleware.Builder) http.Handler Init() RegisterConsumer(mediaType string, consumer runtime.Consumer) RegisterProducer(mediaType string, producer runtime.Producer) AddMiddlewareFor(method, path string, builder middleware.Builder) }
API is a set of functions of a swagger-generated API
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is a parameter option that defines a server parameter
func WithAPIDefaults ¶
func WithAPIDefaults() Option
WithAPIDefaults sets default values to API fields
func WithAPIKeyAuthenticator ¶
func WithAPIKeyAuthenticator( f func(string, string, security.TokenAuthentication) runtime.Authenticator) Option
WithAPIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. It has a default implementation in the security package, however you can replace it for your particular usage.
func WithBasicAuthenticator ¶
func WithBasicAuthenticator( f func(security.UserPassAuthentication) runtime.Authenticator) Option
WithBasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. It has a default implementation in the security package, however you can replace it for your particular usage.
func WithBearerAuthenticator ¶
func WithBearerAuthenticator( f func(string, security.ScopedTokenAuthentication) runtime.Authenticator) Option
WithBearerAuthenticator BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. It has a default implementation in the security package, however you can replace it for your particular usage.
func WithBinProducer ¶
WithBinProducer BinProducer registers a producer for the following mime types:
- application/octet-stream
func WithCleanupTimeout ¶
WithCleanupTimeout grace period for which to wait before killing idle connections
func WithCommandLineOptionsGroups ¶
func WithCommandLineOptionsGroups(g []swag.CommandLineOptionsGroup) Option
WithCommandLineOptionsGroups Custom command line argument groups with their descriptions
func WithConfiguredAPI ¶
func WithConfiguredAPI() Option
WithConfiguredAPI runs generated API configuration function of swagger server. Normally it runs functions defined in `configure_*.go` file, where you has to define your handlers and settings in a classic go-swagger generated server.
You may add this option if you want to setup some defaults defined there. But you don't need it if you set up the server configuration yourself using the Plugger
func WithEnabledListeners ¶
WithEnabledListeners the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec
func WithGracefulTimeout ¶
WithGracefulTimeout grace period for which to wait before shutting down the server
func WithHTMLProducer ¶
WithHTMLProducer HTMLProducer registers a producer for the following mime types:
- text/html
func WithJSONConsumer ¶
WithJSONConsumer JSONConsumer registers a consumer for the following mime types:
- application/json
func WithJSONProducer ¶
WithJSONProducer JSONProducer registers a producer for the following mime types:
- application/json
func WithKeepAlive ¶
WithKeepAlive sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)
func WithListenLimit ¶
WithListenLimit limit the number of outstanding requests
func WithLogger ¶
WithLogger User defined logger function
func WithMaxHeaderSize ¶
WithMaxHeaderSize controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size of the request body.
func WithPreServerShutdown ¶
func WithPreServerShutdown(f func()) Option
WithPreServerShutdown PreServerShutdown is called before the HTTP(S) server is shutdown This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic
func WithReadTimeout ¶
WithReadTimeout maximum duration before timing out read of the request
func WithServeError ¶
WithServeError ServeError is called when an error is received, there is a default handler but you can set your own with this
func WithServerDefaults ¶
func WithServerDefaults() Option
WithServerDefaults sets default values to server fields
func WithServerShutdown ¶
func WithServerShutdown(f func()) Option
WithServerShutdown ServerShutdown is called when the HTTP(S) server is shut down and done handling all active connections and does not accept connections any more
func WithSocketPath ¶
WithSocketPath the unix socket to listen on
func WithTLSCACertificate ¶
WithTLSCACertificate the certificate authority file to be used with mutual tls auth
func WithTLSCertificate ¶
WithTLSCertificate the certificate to use for secure connections
func WithTLSCertificateKey ¶
WithTLSCertificateKeyTLSCertificateKey the private key to use for secure connections
func WithTLSKeepAlive ¶
WithTLSKeepAlive sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)
func WithTLSListenLimit ¶
WithTLSListenLimit limit the number of outstanding requests
func WithTLSPort ¶
WithTLSPort the port to listen on for secure connections, defaults to a random value
func WithTLSReadTimeout ¶
WithTLSReadTimeout maximum duration before timing out read of the request
func WithTLSWriteTimeout ¶
WithTLSWriteTimeout maximum duration before timing out write of the response
func WithWriteTimeout ¶
WithWriteTimeout maximum duration before timing out write of the response
type Plug ¶
type Plug struct {
// contains filtered or unexported fields
}
Plug is a Swagger API wrapper to make it plugable
func NewPlug ¶
NewPlug creates a new Swagger API plug
srv is a code-generated go-swagger server. api is a code-generated go-swagger api opts is a set of api or server options of your choice
Note that if you predefine any fields of the API or the Server, options will override them
You can also still use the server structure to parse command-line flags using "github.com/jessevdk/go-flags" library as go-swagger does
type Server ¶
type Server interface { ConfigureAPI() Logf(f string, args ...interface{}) Fatalf(f string, args ...interface{}) Serve() (err error) Listen() error Shutdown() error GetHandler() http.Handler SetHandler(handler http.Handler) UnixListener() (net.Listener, error) HTTPListener() (net.Listener, error) TLSListener() (net.Listener, error) }
Server is a set of functions of a swagger-generated server
Directories ¶
Path | Synopsis |
---|---|
example
|
|
simple_server/restapi
Package restapi Greeting Server Schemes: http Host: localhost BasePath: / Version: 1.0.0 Consumes: - application/json Produces: - text/plain swagger:meta
|
Package restapi Greeting Server Schemes: http Host: localhost BasePath: / Version: 1.0.0 Consumes: - application/json Produces: - text/plain swagger:meta |