This repository was archived by the owner on Jun 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
HttpHeaderAttribute
Jussi Saarivirta edited this page Jan 26, 2019
·
1 revision
Annotation for a HttpParam indicating that its value comes from the HttpRequest headers.
Contains the Name (indicates the header name) and Required (if true, throws exception when header not provided) properties.
Default deserialization can convert header values into objects, assuming that the provided value is valid JSON.
GET http://localhost:7071/api/header-basics
x-my-header: hello world
x-my-json-header: {"name": "John"}
[FunctionName("HeaderParametersDemo1")]
public static async Task<IActionResult> HeaderParametersDemo1(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "header-basics")] HttpRequest req,
[HttpHeader(Name = "x-my-header")]HttpParam<string> myBasicHeader,
[HttpHeader(Name = "x-my-json-header")]HttpParam<MyObject> myJsonHeader,
ILogger log)
{
log.LogInformation($"x-my-header: {myBasicHeader}");
log.LogInformation($"x-my-json-header: {JsonConvert.SerializeObject(myJsonHeader.Value)}");
return new OkObjectResult("see the log");
}Table of contents
- Overview
- Authentication and authorization
- Exception handling
- HttpParam Attributes
-
Classes and interfaces overview
- Implementable interfaces
- Infrastructure classes