Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Serve ¶
func Serve(source *workloadapi.X509Source, serverStarted chan<- bool) error
Serve initializes and starts an mTLS-secured HTTP server using the given X509Source and TLS configuration. It also signals that the server has started by sending a message on the provided channel.
Parameters:
- source: A pointer to workloadapi.X509Source, which provides X.509 SVIDs for mTLS.
- serverStarted: A channel that will receive a boolean value to signal server startup.
Returns:
- error: An error object if the server fails to start or run; otherwise, returns nil.
The function performs the following operations:
- Validates the source and initializes routes.
- Sets up a custom authorizer using the TLS configuration.
- Configures and starts the HTTP server with mTLS enabled.
- Signals server startup by sending a boolean value on the `serverStarted` channel.
- Listens and serves incoming HTTP requests.
The function will return an error if any of the following conditions occur:
- The source is nil.
- Server fails to listen and serve.
Note: Serve should be called only once during the application lifecycle to initialize the HTTP server.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.