Refit 2.1.0
What's New
Generic Interface Support (#70)
Thanks to @bennor, you can now define generic interfaces that apply to multiple APIs:
public interface IReallyExcitingCrudApi<T, in TKey> where T : class
{
[Post("")]
Task<T> Create([Body] T paylod);
[Get("")]
Task<List<T>> ReadAll();
[Get("/{key}")]
Task<T> ReadOne(TKey key);
[Put("/{key}")]
Task Update(TKey key, [Body]T payload);
[Delete("/{key}")]
Task Delete(TKey key);
}
// Later, in another part of town...
var userApi = RestService.For<IReallyExcitingCrudApi<User, string>>("http://api.example.com/users");
var adminApi = RestService.For<IReallyExcitingCrudApi<Admin, string>>("http://api.example.com/admins");
URL Parameter Formatting (#66)
Thanks to @carl-berg, types that are serialized in the URL query string can now define custom formatting, via a new RefitSettings
class that is optionally passed to RestService.For
.