Documentation ¶
Index ¶
- Variables
- func GetReadyChannel() chan bool
- func GetServerPort() (int, error)
- func RunServer(ctx context.Context, grpcPort int, httpPort int, ...) (err error)
- func StopServer(ctx context.Context)
- type ServerConfigOption
- func WithAdditionalHandler(method string, path string, h runtime.HandlerFunc) ServerConfigOption
- func WithAllowedHeaders(headers []string) ServerConfigOption
- func WithAllowedMethods(methods []string) ServerConfigOption
- func WithAllowedOrigins(origins []string) ServerConfigOption
- func WithEmbeddedOAuth2Server(keyPath string, keyPassword string, saveOnCreate bool, ...) ServerConfigOption
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultAllowedOrigins contains a nil slice, as per default, no origins are allowed. DefaultAllowedOrigins []string = nil // DefaultAllowedHeaders contains sensible defaults for the Access-Control-Allow-Headers header. // Please adjust accordingly in production using WithAllowedHeaders. DefaultAllowedHeaders = []string{"Content-Type", "Accept", "Authorization"} // DefaultAllowedMethods contains sensible defaults for the Access-Control-Allow-Methods header. // Please adjust accordingly in production using WithAllowedMethods. DefaultAllowedMethods = []string{"GET", "POST", "PUT", "DELETE"} // DefaultAPIHTTPPort specifies the default port for the REST API. DefaultAPIHTTPPort int16 = 8080 )
Functions ¶
func GetReadyChannel ¶ added in v1.4.0
func GetReadyChannel() chan bool
GetReadyChannel returns a channel which will notify when the server is ready
func GetServerPort ¶ added in v1.3.13
GetServerPort returns the actual port used by the REST API
func RunServer ¶
func RunServer(ctx context.Context, grpcPort int, httpPort int, serverOpts ...ServerConfigOption) (err error)
RunServer starts our REST API. The REST API is a reverse proxy using grpc-gateway that exposes certain gRPC calls as RESTful HTTP methods.
func StopServer ¶ added in v1.3.14
StopServer is in charge of stopping the REST API.
Types ¶
type ServerConfigOption ¶ added in v1.4.0
ServerConfigOption represents functional-style options to modify the server configuration in RunServer.
func WithAdditionalHandler ¶ added in v1.4.0
func WithAdditionalHandler(method string, path string, h runtime.HandlerFunc) ServerConfigOption
WithAdditionalHandler is an option to add an additional handler func in the REST server.
func WithAllowedHeaders ¶ added in v1.3.13
func WithAllowedHeaders(headers []string) ServerConfigOption
WithAllowedHeaders is an option to supply allowed headers in CORS.
func WithAllowedMethods ¶ added in v1.3.13
func WithAllowedMethods(methods []string) ServerConfigOption
WithAllowedMethods is an option to supply allowed methods in CORS.
func WithAllowedOrigins ¶ added in v1.3.13
func WithAllowedOrigins(origins []string) ServerConfigOption
WithAllowedOrigins is an option to supply allowed origins in CORS.
func WithEmbeddedOAuth2Server ¶ added in v1.4.0
func WithEmbeddedOAuth2Server(keyPath string, keyPassword string, saveOnCreate bool, opts ...oauth2.AuthorizationServerOption) ServerConfigOption
WithEmbeddedOAuth2Server configures our REST gateway to include an embedded OAuth 2.0 authorization server with the given parameters. This server can be used to authenticate and authorize API clients, such as our own micro-services as well as users logging in through the UI.
For the various options to configure the OAuth 2.0 server, please refer to https://pkg.go.dev/github.com/oxisto/oauth2go#AuthorizationServerOption.
In production scenarios, the usage of a dedicated authentication and authorization server is recommended.