5.38Inheritance and Reuse

Created on Aug 17, 2026~1 min read

HTTP declarative requests support object-oriented features such as encapsulation and inheritance. Common interfaces can be defined in parent interfaces and then inherited by derived interfaces to achieve reuse. For example:

cs
public interface IHttpBaseService : IHttpDeclarative{    [Get("https://furion.net/")]    Task<string> GetStringAsync();}public interface IHttp1 : IHttpBaseService{    [Get("https://baiqian.com/")]    Task<string> GetWebsiteAsync();}

Additionally, inheritance from ordinary interfaces that do not implement the IHttpDeclarative interface is also supported, for example:

cs
public interface IHttpNormal{    [Get("https://baiqian.com/")]    Task<string> GetBaiduAsync();}public interface IHttp2 : IHttpNormal, IHttpBaseService{    // ...}

With encapsulation and inheritance, code can be organized and reused more efficiently.