Table of Contents

Class RequestIdentifierOptions

Namespace
Cuemon.AspNetCore.Http.Headers
Assembly
Cuemon.AspNetCore.dll

Configuration options for RequestIdentifierMiddleware.

public class RequestIdentifierOptions : IValidatableParameterObject, IParameterObject
Inheritance
RequestIdentifierOptions
Implements

Examples

The following example demonstrates how to configure to customize the Request-ID header name and token generator.

using System;
using Cuemon.Messaging;

        namespace Cuemon.AspNetCore.Http.Headers;

        public static class RequestIdentifierOptionsExample
        {
            public static void Demonstrate()
            {
                var options = new RequestIdentifierOptions
        {
            Token = new RequestToken("req-42")
        };

        options.ValidateOptions();
        Console.WriteLine(options.Token.RequestId);
            }
        }

Constructors

RequestIdentifierOptions()

Initializes a new instance of the RequestIdentifierOptions class.

public RequestIdentifierOptions()

Remarks

The following table shows the initial property values for an instance of RequestIdentifierOptions.

PropertyInitial Value
HeaderNameXRequestId
TokenDynamicRequest.Create(Guid.NewGuid().ToString("N")

Properties

HeaderName

Gets or sets the name of the correlation identifier HTTP header.

public string HeaderName { get; set; }

Property Value

string

The name of the correlation identifier HTTP header.

Token

Gets or sets the IRequestToken that provides a Request ID implementation.

public IRequestToken Token { get; set; }

Property Value

IRequestToken

The IRequestToken that provides a Request ID implementation.

Methods

ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

public void ValidateOptions()

Remarks

This method is expected to throw exceptions when one or more conditions fails to be in a valid state.

Exceptions

InvalidOperationException

HeaderName cannot be null, empty or consist only of white-space characters - or - Token cannot be null.