DEV Community

loading...

Retrofit Core for .NET Core

akashkava profile image Akash Kava ・1 min read

Retrofit Core

  1. No build step
  2. Dynamic Service Proxy generator
  3. Support for Header as property

Example


public interface IBackendService {

    // when set, it will always be sent with
    // every request
    [Header("access-key")]
    AccessKey { get; set; }

    [Get("/location/{ip}")]
    Task<IPInfo> GetLocationInfoAsync([Path("ip")] string ip);

    [Post("/location/{ip}")]
    Task<IPInfo> SaveLocationInfoAsync([Body] IPInfo info);

    // retrive http response for detailed response
    [Get("/video/{id}.mp4")]
    Task<HttpResponseMessage> GetRawResponse([Query("id")] string id);

    [Get("/voice/{id}.mp3")]
    Task<byte[]> GetByteArray([Query("id")] string id);
}

Usage


    var client = RetroClient
       .Create<IBackendService, BaseService>(
           new Uri("base url...") , httpClient);

neurospeech / retro-core-fit

REST Library similar to Retrofit for .NET Core

Retrofit Core

  1. No build step
  2. Dynamic Service Proxy generator
  3. Support for Header as property

Example

public interface IBackendService {
    // when set, it will always be sent with
    // every request
    [Header("access-key")]
    AccessKey { get; set; }
    [Get("/location/{ip}")]
    Task<IPInfo> GetLocationInfoAsync([Path("ip")] string ip)
    [Post("/location/{ip}")]
    Task<IPInfo> SaveLocationInfoAsync([Body] IPInfo info);
    
    // retrive http response for detailed response
    [Get("/video/{id}.mp4")]
    Task<HttpResponseMessage> GetRawResponse([Query("id")] string id);
    
    [Get("/voice/{id}.mp3")]
    Task<byte[]> GetByteArray([Query("id")] string id);
}

Usage

    var client = RetroClient.Create<IBackendService, BaseService>( new Uri(

Discussion (0)

Forem Open with the Forem app