Show / Hide Table of Contents

Class SimpleRouter

A delegator that provides simple request path/method matching. The request is sent to the handler for the first matching path. If there is no matching path, it returns a 404. If there is a matching path but only for a different HTTP method, it returns a 405.

Inheritance
System.Object
SimpleRouter
Namespace: LaunchDarkly.TestHelpers.HttpTest
Assembly: LaunchDarkly.TestHelpers.dll
Syntax
public sealed class SimpleRouter : Object

Constructors

SimpleRouter()

Declaration
public SimpleRouter()

Properties

Handler

Returns the stable Handler that is the external entry point to this delegator. This is used implicitly if you use a SimpleRouter anywhere that a Handler is expected.

Declaration
public Handler Handler { get; }
Property Value
Type Description
Handler

Methods

AddPath(HttpMethod, String, Handler)

Adds an exact-match path, specifying the HTTP method.

Declaration
public SimpleRouter AddPath(HttpMethod method, string path, Handler handler)
Parameters
Type Name Description
System.Net.Http.HttpMethod method

the desired method

System.String path

the desired path

Handler handler

the handler to call for a matching request

Returns
Type Description
SimpleRouter

the same instance

AddPath(String, Handler)

Adds an exact-match path.

Declaration
public SimpleRouter AddPath(string path, Handler handler)
Parameters
Type Name Description
System.String path

the desired path

Handler handler

the handler to call for a matching request

Returns
Type Description
SimpleRouter

the same instance

AddRegex(HttpMethod, String, Handler)

Adds a regex path pattern, specifying the HTTP method. If it contains any capture groups, the matched groups will be available from GetPathParam(Int32).

Declaration
public SimpleRouter AddRegex(HttpMethod method, string pattern, Handler handler)
Parameters
Type Name Description
System.Net.Http.HttpMethod method

the desired method

System.String pattern

the regex to match

Handler handler

the handler to call for a matching request

Returns
Type Description
SimpleRouter

the same instance

AddRegex(String, Handler)

Adds a regex path pattern. If it contains any capture groups, the matched groups will be available from GetPathParam(Int32).

Declaration
public SimpleRouter AddRegex(string pattern, Handler handler)
Parameters
Type Name Description
System.String pattern

the regex to match

Handler handler

the handler to call for a matching request

Returns
Type Description
SimpleRouter

the same instance

Operators

Implicit(SimpleRouter to Handler)

Declaration
public static implicit operator Handler(SimpleRouter me)
Parameters
Type Name Description
SimpleRouter me
Returns
Type Description
Handler
In This Article
Back to top Generated by DocFX