{"id":32420761,"url":"https://github.com/mynihongo/fluenthttp","last_synced_at":"2025-10-25T17:58:23.729Z","repository":{"id":37100690,"uuid":"445796001","full_name":"MyNihongo/FluentHttp","owner":"MyNihongo","description":"Fluent wrapper around IHttpClientFactory","archived":false,"fork":false,"pushed_at":"2025-04-21T01:02:49.000Z","size":210,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-10T04:26:27.262Z","etag":null,"topics":["fluent","http","httpclient","httpclientfactory"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MyNihongo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2022-01-08T11:05:21.000Z","updated_at":"2025-04-18T08:38:31.000Z","dependencies_parsed_at":"2023-02-19T13:16:10.962Z","dependency_job_id":"80754d67-c7a3-4934-bdd8-0b052415b0aa","html_url":"https://github.com/MyNihongo/FluentHttp","commit_stats":{"total_commits":92,"total_committers":3,"mean_commits":"30.666666666666668","dds":"0.19565217391304346","last_synced_commit":"2ea1744de8e30507fe8e0f5a04320ffa81b2e4c9"},"previous_names":["mynihongo/httpservice"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/MyNihongo/FluentHttp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyNihongo%2FFluentHttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyNihongo%2FFluentHttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyNihongo%2FFluentHttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyNihongo%2FFluentHttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MyNihongo","download_url":"https://codeload.github.com/MyNihongo/FluentHttp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyNihongo%2FFluentHttp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280995963,"owners_count":26426667,"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-25T02:00:06.499Z","response_time":81,"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":["fluent","http","httpclient","httpclientfactory"],"created_at":"2025-10-25T17:57:59.281Z","updated_at":"2025-10-25T17:58:23.718Z","avatar_url":"https://github.com/MyNihongo.png","language":"C#","readme":"[![Version](https://img.shields.io/nuget/v/MyNihongo.FluentHttp?style=plastic)](https://www.nuget.org/packages/MyNihongo.FluentHttp/)\n[![Nuget downloads](https://img.shields.io/nuget/dt/MyNihongo.FluentHttp?label=nuget%20downloads\u0026logo=nuget\u0026style=plastic)](https://www.nuget.org/packages/MyNihongo.FluentHttp/)   \n\n# FluentHttp\nFluent wrapper around IHttpClientFactory  \nInstall a NuGet package `MyNihongo.FluentHttp`.\n\n## Configuration\nAdd a section to `IConfiguration`\n```json\n{\n\t\"FluentHttp\": {\n\t\t\"BaseAddress\": \"https://jsonplaceholder.typicode.com\",\n\t\t\"NtlmEnabled\": false,\n\t\t\"Timeout\": 100\n\t} \n}\n```\n- `Timeout` in seconds. for `Timeout.Infinite` pass -1.\n\nRegister a service\n```cs\nusing MyNihongo.FluentHttp;\n\nservices.AddFluentHttp();\n\n// Or optionally configure the HTTP client\nservices.AddFluentHttp((services, httpClient) =\u003e\n{\n\t// configure\n});\n```\n\n## HTTP methods\nTo optimize JSON serialization `JsonTypeInfo\u003cT\u003e` can be supplied for all methods. More info about these types [here](https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-source-generator/).  \nIn further examples a variable `IFluentHttp fluentHttp` will be used.  \n\n#### GetJsonAsync\nGets a JSON stream.\n```cs\n[JsonSerializable(typeof(RecordContext[]))]\ninternal partial class RecordContext : JsonSerializerContext {}\n\npublic sealed record RecordContext\n{\n\tpublic int Id { get; set; }\n}\n\n// Get the model\nvar models = await fluentHttp\n\t.AppendPathSegment(\"example\")\n\t.GetJsonAsync(RecordContext.Default.RecordArray, ct);\n\n// When an API may return non-JSON values (e.g. `\"\"`) this method can be used in order to ignore parsing exceptions\nfluentHttp.GetJsonOrDefaultAsync(RecordContext.Default.RecordArray, ct);\n```\n\n#### PostJsonAsync\nPosts a JSON model and gets the JSON response.\n```cs\n[JsonSerializable(typeof(Request))]\ninternal partial class RequestContext : JsonSerializerContext {}\n\n[JsonSerializable(typeof(Response))]\ninternal partial class ResponseContext : JsonSerializerContext {}\n\nvar req = new Request\n{\n\tData = \"example\"\n};\n\nvar response = await fluentHttp\n\t.AppendPathSegment(\"example\")\n\t.PostJsonAsync(req, RequestContext.Default.Request, ResponseContext.Default.Response, ct);\n\n// When an API may return non-JSON values (e.g. `\"\"`) this method can be used in order to ignore parsing exceptions\nfluentHttp.PostJsonOrDefaultAsync(req, RequestContext.Default.Request, ResponseContext.Default.Response, ct);\n```\n\n## Fluent extensions\nFluent extensions supply additional parameters for the main HTTP methods.\n\n#### AppendPathSegment\nAppends a new section to the request URI.\n```cs\n// get from https://jsonplaceholder.typicode.com/posts\nvar result = await fluentHttp\n\t.AppendPathSegment(\"posts\")\n\t.GetJsonAsync\u003cPostRecord\u003e();\n```\n\n#### AppendPathSegments\nAppends multiple sections to the request URI.\n```cs\n// get from https://jsonplaceholder.typicode.com/posts/1/comments\nvar result = await fluentHttp\n\t.AppendPathSegment(\"posts\", \"1\", \"comments\")\n\t.GetJsonAsync\u003cPostCommentRecord\u003e();\n```\n\n#### AppendParameter\nAppends a URL parameter\n```cs\n// get from https://jsonplaceholder.typicode.com/posts?value=123\nvar result = await fluentHttp\n\t.AppendPathSegment(\"posts\")\n\t.AppendParameter(\"value\", \"123\")\n\t.GetJsonAsync\u003cPostCommentRecord\u003e();\n```\n\n#### WithHeader\nAppends a header to the request.\n```cs\nvar result = await fluentHttp\n\t.AppendPathSegment(\"posts\")\n\t.WithHeader(\"my-header\", \"value\")\n\t.GetJsonAsync\u003cPostRecord\u003e();\n```\n\n#### Basic authentication\nAppend the authentication header for the basic authentication\n```cs\nvar result = await fluentHttp\n\t.AppendPathSegment(\"posts\")\n\t.WithBasicAuth(\"username\", \"strong password\")\n\t.GetJsonAsync\u003cPostRecord\u003e();\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmynihongo%2Ffluenthttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmynihongo%2Ffluenthttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmynihongo%2Ffluenthttp/lists"}