Skip to content

Simplification of the default HttpClient for the dotnet core framework

License

Notifications You must be signed in to change notification settings

dayvster/Volt-Http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Volt-Http

Volt is a simplified HttpClient for the dotnet core Framework.

Installation

PM> Install-Package Volt.DayviSchuster

Usage

The client itself is relatively easy to use.

Below you will find a simple code example on how to use the library in a console application, of course you are free to use it in any kind of dotnet core application you would like.

Example:

using Arctekdev.Volt;
using System;
namespace Vtest{
    class Program {
        static void Main(string[] args){ 
            // Let's just send a very simple GET request
            string result = VHttp.Get(new Uri("https://httpbin.org/get")).Content.ReadAsStringAsync().Result;

            // And print it to the console
            Console.WriteLine(result);
        }
    }
}

if you did everything right then the output should be something along these lines:

Output

{
  "args": {},
  "headers": {
    "Accept-Encoding": "gzip, deflate",
    "Connection": "close",
    "Host": "httpbin.org"
  },
  "origin": "90.153.6.52",
  "url": "https://httpbin.org/get"
}

Post Request

    VHttp.Post(
        new Uri("https://httpbin.org/post"), 
        "supercalifragilisticexpialidocious",
        "text/plain"
    ).Content.ReadAsStringAsync().Result();

Chainable

    VHttp.SendPost(
        new Uri("https://httpbin.org/post"), 
        "supercalifragilisticexpialidocious", 
        "text/plain"
    ).GetResultAsString();

The main difference between the two above methods is the return type, methods prefixed with Send will always return the instance of the VClient, which allows you to chain methods, whereas methods like Post, Get, Put will always have a return type of HttpResponseMessage

About

Simplification of the default HttpClient for the dotnet core framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages