This repository was archived by the owner on Apr 10, 2025. It is now read-only.
  
  
  - 
                Notifications
    You must be signed in to change notification settings 
- Fork 2
Solid.Http.Core Extending
        Gísli Konráð Björnsson edited this page Jan 16, 2019 
        ·
        4 revisions
      
    SolidHttp is created with extensions and you can create your own quite easily.
Here are some examples on how to extend SolidHttpRequest. The first adds a function that adds a header with key "x-standard-header" and fixed text value "standard". The second example adds a function that adds a authorization header with a bearer token.
public static class StandardHeaderExtensions
{
    public static ISolidHttpRequest WithProprietaryHeader(this ISolidHttpRequest request)
    {
        return request.WithHeader("x-proprietary-header", "I am proprietary");
    }
    public static ISolidHttpRequest WithBearerToken(this ISolidHttpRequest request, string token)
    {
        return request.WithHeader("Authorization", $"Bearer {token}");
    }
}ISolidHttpRequest is not the only useful thing to extend. Solid.Http.Core has multiple extensions classes where you can get some ideas on how to to create your own by looking them over.