Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neurospeech/retro-core-fit
REST Library similar to Retrofit for .NET Core
https://github.com/neurospeech/retro-core-fit
Last synced: about 2 months ago
JSON representation
REST Library similar to Retrofit for .NET Core
- Host: GitHub
- URL: https://github.com/neurospeech/retro-core-fit
- Owner: neurospeech
- License: mit
- Created: 2018-01-05T09:19:36.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T11:48:28.000Z (almost 2 years ago)
- Last Synced: 2024-08-09T10:52:09.518Z (5 months ago)
- Language: C#
- Homepage:
- Size: 77.1 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Retrofit Core
1. No build step
2. Dynamic Service Proxy generator
3. Support for Header as property
4. Generic RequestBuilder# Example
```c#public interface IBackendService {
// when set, it will always be sent with
// every request
[Header("access-key")]
AccessKey { get; set; }[Get("/location/{ip}")]
Task GetLocationInfoAsync([Path("ip")] string ip);[Post("/location/{ip}")]
Task SaveLocationInfoAsync([Path("ip")] string ip, [Body] IPInfo info);
[Get("/voice/{id}.mp3")]
Task GetByteArrayAsync([Query("id")] string id);
// Response Object with Header
[Get("/projects")]
Task> GetProjectsAsync();// Retrieve http response for detailed response.
// HttpResponseMessage is not disposed, it is responsibility of caller
// to dispose the message (which will close open network streams)
// This will not throw an error message if there was HTTP Error.
[Get("/video/{id}.mp4")]
Task GetRawResponseAsync([Query("id")] string id);// Multi Part Form for uploads...
[Post("/upload")]
Task UploadFile(
// other form element items
[Multipart("name")] string attachmentName,// it can accept stream
[MultipartFile("file1")] Stream fileStream,// it can accept HttpContent which may contain content type
[MultipartFile("file2")] HttpContent someOtherContent
);}
public class GitLabResponse: ApiResponse {
// set by RetroClient when response is received
[Header("x-total-pages")]
public int TotalPages {get;set;}}
```
# Usage
```c#var client = RetroClient.Create( new Uri("base url...") , httpClient);
```
# Request Builder
```c#// get request
RequestBuilder.Get("/location/{ip}")
.Path("ip", ipAddress)
.GetResponseAsync(httpClient);// post request
RequestBuilder.Post("/location/{ip}")
.Path("ip", ipAddress)
.Body(info)
.GetResponseAsync(httpClient);// get raw response
RequestBuilder.Post("/location/{ip}")
.Path("ip", ipAddress)
.Body(info)
.GetResponseAsync(httpClient); // no generics// Multipart Upload
RequestBuilder.Post("/upload")
.Multipart("name", attachmentName)
.MultipartFile("file1", fileStream, fileName: "photo.jpg")
.GetResponseAsync(httpClient);// Get Api Response with Headers...
RequestBuilder.Post("/api/v4/projects/{id}")
.Path("id", projectId)
.GetResponseAsync>(httpClient);public class GitLabResponse: ApiResponse {
// set by RetroClient when response is received
[Header("x-total-pages")]
public int TotalPages {get;set;}}
```