This sample shows you how to work with the custom header utilities in the Azure Health Data Services Toolkit. We'll cover the four different types of headers modifications in this sample.
This sample doesn't contain a full custom operation pipeline, but is scoped to headers only.
This sample doesn't require any setup or any access to Azure Resources because it does everything locally.
This sample covers the following concepts:
- Header modification service configuration.
- Request static headers which are always injected into the request.
- Request match headers which are injected if the header exists on the request.
- Request identity headers which inject a header from a claim in a request bearer token.
- Response static headers which are always injected into the response.
Request header modifications are useful when you want to log information from the incoming request, especially using the header logging capabilities in the FHIR service.
Response header modifications are useful when you want to return headers to the requesting client.
- This repository cloned to your machine and an editor (e.g. Visual Studio or Visual Studio Code).
- Open the
CustomHeaderSample.sln
solution file in Visual Studio or opensamples/FeatureSamples/CustomHeaders
folder in Visual Studio Code. - .NET 8.0 SDK installed on your computer.
Visual Studio Code
From Visual Studio, you can click the "Debug" icon on the left and the play button to run and debug this sample.
Visual Studio
The easiest way to run the sample in Visual Studio is to use the debugger by pressing F5 or select "Debug > Start Debugging".
Command Line
From the command line, you can run the sample by executing dotnet run
in this directory (samples/FeatureSamples/CustomHeaders
).
Program.cs
: Outlines how you can add configuration for custom headers. There are commends in this file - check it out.- Dependency Injection (DI): You should use dependency injection for
IHttpCustomHeaderCollection
in your custom operation pipeline filter. This will provide you the object you need to invoke the header replacement as defined in yourConfigureServices
section inProgram.cs
. IHttpCustomHeaderCollection.AppendAndReplace
: You will need to invoke this inside yourExecuteAsync
method of your filter. This will actually perform the defined header modifications where you want in your pipeline.