Skip to content

Latest commit

 

History

History
45 lines (36 loc) · 1.15 KB

README.md

File metadata and controls

45 lines (36 loc) · 1.15 KB

Solid.Http XML extensions

There is currently one ZIP extension for Solid.Http.Core. The extension uses the System.IO.Compression for deserialization. This package is useful if you need to request a zip archive and manipulate it programmatically.

Solid.Http.Xml

Solid.Http.Zip uses System.IO.Compression internally.

> dotnet add package Solid.Http.Zip

Initialization with Solid.Http.Core

You can add Solid.Http.Zip using the builder.

public void ConfigureServices(IServiceCollection services)
{
    // This call to AddSolidHttpCore could be replaced with AddSolidHttp
    services.AddSolidHttpCore(builder => 
    {
        builder.AddZip(options => 
        {
            options.Mode = ZipArchiveMode.Read;
        });
    });
}

Http response body deserialization

You can also specify the ZipArchiveMode if a specific HTTP endpoint differs from the default.

public async Task<Post> GetAsync(int id)
{
    return await _client
        .GetAsync("posts")
        .WithQueryParameter("zip", true)
        .ExpectSuccess()
        // mode is optional
        .As<Post>(settings, mode: ZipArchiveMode.Read)
    ;
}