DocaLabs.Http.Client 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DocaLabs.Http.Client --version 1.0.0
NuGet\Install-Package DocaLabs.Http.Client -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DocaLabs.Http.Client" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DocaLabs.Http.Client --version 1.0.0
#r "nuget: DocaLabs.Http.Client, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DocaLabs.Http.Client as a Cake Addin
#addin nuget:?package=DocaLabs.Http.Client&version=1.0.0

// Install DocaLabs.Http.Client as a Cake Tool
#tool nuget:?package=DocaLabs.Http.Client&version=1.0.0

The main goal of the library is to minimize plumbing code to bare minimum.

In order to use the library in most cases you would need to define:
* An interface for the remote service.
* A class for request data, properties of that class can be mapped into the HTTP query or to the request body.
* A class for response data, in some cases you won't need to define even that, for example if you want to get a string back.

That's it. The implemnatation is unit test friedly becuase the only thing you are working is against an interface.


For example for Google's street view you would need to define someting like:

   public interface IStreetViewService
   {
       Image Fetch(StreetViewRequest request);
   }

   public class StreetViewRequest
   {
       public GeoLocation location { get; private set; }
       public ImageSize size { get; set; }
       public int? heading { get; set; }
       public int fov { get; set; }
       public int pitch { get; set; }
       public bool sensor { get; set; }
   }

   public class ImageSize
   {
       public int width { get; set; }
       public int height { get; set; }

       public override string ToString()
       {
           return string.Format("{0}x{1}", width, height);
       }
   }

Then inject using the factory (instead of supplying the URL here you can use the app.config file):

HttpClientFactory.CreateInstance<IStreetViewService>(new Uri("http://maps.googleapis.com/maps/api/streetview"));

and finally the call:

var image = service.Fetch(new StreetViewRequest { location = GeoLocation(53.34462, -6.25958), size = new ImageSize { width = 640, height = 300 }, heading = 152, fov = 90 });

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DocaLabs.Http.Client:

Package Downloads
DocaLabs.Http.Client.with.NewtonSoft.Json.Serializer

Strong typed HTTP client with provider using. The main goal of the library is to minimize plumbing code to bare minimum.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 17,337 10/28/2013
2.0.1.2 1,412 9/19/2013
2.0.0.1 1,586 9/16/2013
1.0.1.2 1,196 9/6/2013
1.0.1.1 1,708 4/2/2013
1.0.1 1,272 2/28/2013
1.0.0 1,272 2/23/2013