Class HttpServer
A simplified wrapper for an embedded test HTTP server.
Inheritance
Implements
Namespace: LaunchDarkly.TestHelpers.HttpTest
Assembly: LaunchDarkly.TestHelpers.dll
Syntax
public sealed class HttpServer : Object, IDisposable
Properties
Recorder
Returns the RequestRecorder that captures all requests to this server.
Declaration
public RequestRecorder Recorder { get; }
Property Value
Type | Description |
---|---|
RequestRecorder |
Remarks
This is enabled by default. To turn off capturing of requests, set the Enabled property of this object to false.
Uri
The base URI of the server.
Declaration
public Uri Uri { get; }
Property Value
Type | Description |
---|---|
System.Uri |
Methods
Dispose()
Shuts down the server.
Declaration
public void Dispose()
Start(Handler)
Starts a new test server on an arbitrary available port.
Declaration
public static HttpServer Start(Handler handler)
Parameters
Type | Name | Description |
---|---|---|
Handler | handler | A function that will handle all requests to this server. Use the factory methods in Handlers for standard handlers. If you will need to change the behavior of the handler during the lifetime of the server, use Switchable(out HandlerSwitcher). |
Returns
Type | Description |
---|---|
HttpServer | the started server instance |
Remarks
Make sure to close this when done, by calling Dispose
or with a using
statement.
Start(Int32, Handler)
Starts a new test server on a specific port.
Declaration
public static HttpServer Start(int port, Handler handler)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | port | The port to listen on. |
Handler | handler | A function that will handle all requests to this server. Use the factory methods in Handlers for standard handlers. If you will need to change the behavior of the handler during the lifetime of the server, use Switchable(out HandlerSwitcher). |
Returns
Type | Description |
---|---|
HttpServer | the started server instance |
Remarks
Make sure to close this when done, by calling Dispose
or with a using
statement.