StaticHeaderAttribute Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines a static header to be sent on every API request.
public ref class StaticHeaderAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true)]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class StaticHeaderAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true)>]
[<System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")>]
type StaticHeaderAttribute = class
inherit Attribute
Public NotInheritable Class StaticHeaderAttribute
Inherits Attribute
- Inheritance
- Attributes
Examples
[AutoClient("MyClient")]
[StaticHeader("X-MyHeader", "MyHeaderValue")]
interface IMyDependencyClient
{
[Get("/api/users")]
[StaticHeader("X-GetUsersHeader", "Value")]
public Task<Users> GetUsers(CancellationToken cancellationToken = default);
}
Remarks
Injects a static header to be sent with every request. When this attribute is applied to an interface, then it impacts every method described by the interface. Otherwise, it only affects the method where it is applied. The header name must not be null or empty. The value, on the other hand, can be empty, but not null.
Constructors
StaticHeaderAttribute(String, String) |
Initializes a new instance of the StaticHeaderAttribute class. |
Properties
Header |
Gets the name of the header. |
Value |
Gets the value of the header. |