Skip to content

Adding header at factory creation? #241

Answered by dannythunder
dannythunder asked this question in Q&A
Discussion options

You must be logged in to vote

Oh. I found out. Was not to clear to me.

services.AddRestEaseClient< IMyHttpClient >(baseUrl, new()
            {
                InstanceConfigurer = instance => instance.ApiKey = "myKey"
            });
public interface IMyHttpClient
{
    [Header("apikey")]
    string ApiKey { get; set; }
    
    [Get("/v1/one/ring/to/rule/them/all")]
    Task<ring> Get(CancellationToken cancellationToken);
}

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by dannythunder
Comment options

You must be logged in to vote
3 replies
@canton7
Comment options

@canton7
Comment options

@dannythunder
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants