Class FromHeaderAttribute
properties decorated with this attribute will have their values auto bound from the relevant http header of the current request.
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.Attributes.dll
Syntax
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class FromHeaderAttribute : Attribute
Constructors
FromHeaderAttribute(bool, bool)
properties decorated with this attribute will have their values auto bound from the relevant http header of the current request.
Declaration
public FromHeaderAttribute(bool isRequired, bool removeFromSchema = false)
Parameters
Type | Name | Description |
---|---|---|
bool | isRequired | set to false if a validation error shouldn't be thrown when the current user request doesn't have a header matching the property name being bound to. |
bool | removeFromSchema | set to true if your header is not required but shouldn't be added to schema model. |
FromHeaderAttribute(string?, bool, bool)
properties decorated with this attribute will have their values auto bound from the relevant http header of the current request.
Declaration
public FromHeaderAttribute(string? headerName = null, bool isRequired = true, bool removeFromSchema = false)
Parameters
Type | Name | Description |
---|---|---|
string | headerName | optionally specify the header name to bind from. if not specified, the header name must match the name of the property being bound to. |
bool | isRequired | set to false if a validation error shouldn't be thrown when the current request doesn't have the specified header. |
bool | removeFromSchema | set to true if your header is not required but shouldn't be added to schema model. |
Properties
HeaderName
the header name to auto bind from
Declaration
public string? HeaderName { get; set; }
Property Value
Type | Description |
---|---|
string |
IsRequired
set to true if a validation error should be thrown when the current request doesn't have the specified header
Declaration
public bool IsRequired { get; set; }
Property Value
Type | Description |
---|---|
bool |
RemoveFromSchema
set to true if your header is not required but shouldn't be added to schema model
Declaration
public bool RemoveFromSchema { get; set; }
Property Value
Type | Description |
---|---|
bool |