Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rivantsov/arrest
.NET REST client
https://github.com/rivantsov/arrest
Last synced: about 2 months ago
JSON representation
.NET REST client
- Host: GitHub
- URL: https://github.com/rivantsov/arrest
- Owner: rivantsov
- License: mit
- Created: 2019-11-09T23:18:01.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-09T22:01:21.000Z (6 months ago)
- Last Synced: 2024-10-12T13:24:07.548Z (3 months ago)
- Language: C#
- Size: 86.9 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: ReadMe.MD
- License: LICENSE
Awesome Lists containing this project
README
# ARREST - .NET REST client
**Arrest** is a client-side component for communicating with REST APIs and services. It is a wrapper around HttpClient with a number of convenient methods for automatically serializing/deserializing typed data objects.
Examples:
```c#
var client = new RestClient("http://www.bookstore.com");
var someBooks = await client.GetAsync>("api/books?take={0}", 10);
var theBook = client.Get("api/books/{0}", someBookId); //sync version
var myReview = new BookReview() { ... };
var myReviewBack = await client.PostAsync(myReview, "api/user/reviews");
```
The client handles HTTP status codes returned by the service (throws exceptions on BadRequest and Server errors).
Supports Json serialization. Supports sync and async operations.
See RestCallTests.cs class for examples of use.You can pass additional request headers, and CancellationToken:
```c#
var someBook = await client.GetAsync("api/book/{0}", 123, ("X-Cor-Id", CorId), token);
```You can get response headers and other information about response:
```c#
var contextBox = new ArgContextBox();
var someBook = await client.GetAsync("api/book/{0}", 123, ("X-Cor-Id", CorId), contextBox);
var respHeader = contextBox.GetResponseHeader("X-Cor-Id")?.FirstOrDefault();
var respMessage = contextBox.Response;
```REST client supports automatic retries - just pass a RetryPolicy instance to the constructor