Giter Club home page Giter Club logo

simple.http's People

Contributors

thomasbernard03 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

simple.http's Issues

README Update

SimpleHttpService

twitter_header_photo_2

forthebadge
forthebadge

Installation

You can install the latest version of the package with the command dotnet add package Simple.Http.
You can also install it manualy in your IDE with the nuget package manager by searching Simple.Http.

Getting started

If you're using dependency injection you can register the service thanks to the IHttpService interface. Or, you can use the service manualy by creating a new instance of HttpService.

After this you can use the library.

var simpleHttpResult = await simpleHttpService.SendHttpRequest(url, HttpMethod.Post, body); 

Here we sent an HttpRequest on the route : url with a Post method and a body. In simpleHttpResult we obtain a formatted result :

public class SimpleHttpResult
{
	public Exception Exception { get; set; }
	public HttpStatusCode HttpStatusCode { get; set; }
	public HttpRequestMessage RequestMessage { get; set; }
}

If an Exception is thrown we can get it into Exception. HttpStatusCode refer to the HttpStatusCode's request. The request message is the message sent to our url.

// Send a get method and get the request's content
var simpleHttpResult = await simpleHttpService.SendHttpRequest<MyDTO>(url, HttpMethod.Get); 

MyDTO class can be like this :

public class MyDTO
{
	[JsonProperty("name")]
	public string Name { get; set; }
}

If we want to get returned our request's content we must use the method SendHttpRequest. We can get the returned value in the Result property.

public class SimpleHttpResult
{
	public Exception Exception { get; set; }
	public HttpStatusCode HttpStatusCode { get; set; }
	public HttpRequestMessage RequestMessage { get; set; }
  	public TResult Result { get; set; }
}

That's all !

If you want to help the project, you can put a star on Github. If you have any problems, please let me know by creating an issue on Github or by asking for a pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.