{"id":16366668,"url":"https://github.com/lecaillon/restack","last_synced_at":"2025-10-11T23:19:27.713Z","repository":{"id":77262882,"uuid":"103784380","full_name":"lecaillon/Restack","owner":"lecaillon","description":"Restack is an easy to declare and inject, autogenerated proxy for an HTTP service.","archived":false,"fork":false,"pushed_at":"2019-10-13T21:08:52.000Z","size":561,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-30T23:15:16.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lecaillon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-16T21:19:02.000Z","updated_at":"2022-09-01T21:29:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d75244e-90c5-4edf-b458-ad994057777a","html_url":"https://github.com/lecaillon/Restack","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lecaillon/Restack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lecaillon%2FRestack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lecaillon%2FRestack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lecaillon%2FRestack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lecaillon%2FRestack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lecaillon","download_url":"https://codeload.github.com/lecaillon/Restack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lecaillon%2FRestack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009376,"owners_count":26084579,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T02:47:13.887Z","updated_at":"2025-10-11T23:19:27.690Z","avatar_url":"https://github.com/lecaillon.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Restack\nRestack is an easy to declare and inject, autogenerated proxy for an HTTP service. The idea is to make a full featured resilient HTTP client. It's inspired by the David Fowler's project [RestSample](https://github.com/davidfowl/RestSample) and forked from Ryan Nowak work on [Kickr](https://github.com/glennc/Kickr).\n\nIts implementation is based on:\n- [refit](https://github.com/paulcbetts/refit)\n- [Polly](https://github.com/App-vNext/Polly)\n- [consul](https://github.com/hashicorp/consul)\n\n### Example of the refit / Polly support\n\n1. Define an interface for your rest service.\n    ````csharp\n    public interface IGeoApi\n    {\n        [Get(\"/regions\")]\n        Task\u003cIEnumerable\u003cRegion\u003e\u003e GetRegionsAsync();\n    }\n    ````\n1. Configure the URL for your service and add some http request headers and policies.\n    ```csharp\n    public void ConfigureServices(IServiceCollection services)\n    {\n        services.AddMvc();\n        \n        services.AddRestack() // configure Restack HttpClientFactory\n                .AddPolly();  // configure Polly\n\n        services.AddRestackGlobalHeaders(o =\u003e o.Headers.Add(\"user-agent\", \"myagent\"));\n\n        services.AddRestClient\u003cIGeoApi\u003e(\"https://geo.api.gouv.fr\")\n                .AddRestackHeaders\u003cIGeoApi\u003e(o =\u003e o.Headers.Add(\"api-key\", \"xxxxx-xxx-xxxxxxxx\"))\n                .AddRestackPolicy\u003cIGeoApi\u003e(b =\u003e b.RetryAsync())\n                .AddRestackPolicy\u003cIGeoApi\u003e(b =\u003e b.CircuitBreakerAsync(1, TimeSpan.FromSeconds(5)));\n    }\n    ```\n1. Consume the interface via RestClient\\\u003cT\\\u003e.\n    ```csharp\n    public class HomeController : Controller\n    {\n        private readonly IGeoApi _geoApi;\n\n        public HomeController(IRestClient\u003cIGeoApi\u003e geoApiClient)\n        {\n            _geoApi = geoApiClient.Client;\n        }\n\n        [HttpGet(\"/\")]\n        public async Task\u003cIActionResult\u003e Get()\n        {\n            var regions = await _geoApi.GetRegionsAsync();\n\n            return Ok(regions);\n        }\n    }\n    ```\n\n### Example of the ASP.NET MVC HttpClient param binding support\n\n1. Configure some http request headers for the \"github\" named http client\".\n    ```csharp\n    public void ConfigureServices(IServiceCollection services)\n    {\n        services.AddMvc()\n                .AddRestackModelBinder(); // configure Restack MVC\n        \n        services.AddRestack(); // configure Restack HttpClientFactory\n\n        services.AddRestackGlobalHeaders(o =\u003e o.Headers.Add(\"user-agent\", \"myagent\"));\n        services.AddRestackHeaders(\"github\", o =\u003e o.Headers.Add(\"Accept\", \"application/vnd.github.v3+json\"));\n    }\n    ```\n1. Consume the HttpClient.\n    ```csharp\n    public class HomeController : Controller\n    {\n        public async Task\u003cIActionResult\u003e Index([HttpClientName(\"github\")]HttpClient client)\n        {\n            var response = await client.GetAsync(\"https://api.github.com/users/lecaillon\");\n            ...\n        }\n    }\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flecaillon%2Frestack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flecaillon%2Frestack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flecaillon%2Frestack/lists"}