{"id":22117716,"url":"https://github.com/prosumma/httpfluent","last_synced_at":"2025-03-24T06:14:19.660Z","repository":{"id":85504715,"uuid":"252853857","full_name":"Prosumma/HTTPFluent","owner":"Prosumma","description":"A fluent interface over REST written in Swift","archived":false,"fork":false,"pushed_at":"2023-04-15T06:51:46.000Z","size":86,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T11:46:16.661Z","etag":null,"topics":["http","rest","rest-client","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/Prosumma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-04-03T22:16:58.000Z","updated_at":"2022-01-09T03:17:58.000Z","dependencies_parsed_at":"2023-03-05T12:15:37.358Z","dependency_job_id":null,"html_url":"https://github.com/Prosumma/HTTPFluent","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prosumma%2FHTTPFluent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prosumma%2FHTTPFluent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prosumma%2FHTTPFluent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prosumma%2FHTTPFluent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Prosumma","download_url":"https://codeload.github.com/Prosumma/HTTPFluent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245217935,"owners_count":20579300,"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","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":["http","rest","rest-client","swift"],"created_at":"2024-12-01T13:38:47.603Z","updated_at":"2025-03-24T06:14:19.655Z","avatar_url":"https://github.com/Prosumma.png","language":"Swift","readme":"# HTTPFluent\n\nHTTPFluent provides a fluent interface over HTTP, primarily designed to work with APIs. HTTPFluent supports three styles: callback, `async` (with Swift \u003e= 5.5) and Combine (on Apple platforms).\n\n## Integration\n\nHTTPFluent is available only via Swift Package Manager.\n\n## Usage\n\nHTTPFluent is extremely intuitive to use, so a few examples will suffice:\n\n```swift\nlet id = 2349713\nlet jwt = \"xyz123\"\n\nlet request = URLClient(url: \"https://myapi.com\")\n  .path(\"user\", id)\n  .authorization(bearer: jwt)\n  .post(json: User(name: \"Don Quixote\"))\n\n// Callback style\nrequest.receive(json: User.self) { result in\n  do {\n    let user = try result.get()\n  } catch {\n    // Oops, no user\n  }\n}\n\n// Async style\nlet user = try await request.receive(json: User.self)\n\n// Combine style\nrequest.receivePublisher(json: User.self)\n  .sink { completion in\n    // Handle completion\n  } receiveValue: { user in\n    // Do something with user\n  }\n  .store(in: \u0026cancellables)\n```\n\nHTTPFluent can also be used to generate a `URLRequest` without invoking it.\n\n```swift\nlet urlRequest = URLClient(url: \"https://myapi.com\")\n  .path(\"user\", id)\n  .authorization(bearer: jwt)\n  .put(data: data) // Here we put raw data instead of JSON.\n  .request\n```\n\nHTTPFluent uses immutable state. Each step in the chain to build the `URLRequest` copies a `URLRequestBuilder` struct. All operations are thus additive, encouraging reuse.\n\n```swift\n// Set up the shared information about the request.\nlet fluent = URLClient(url: \"https://myapi.com\")\n  .authorization(bearer: jwt)\n  .path(\"user\")\n\n// This adds the value of id as a path element, so the result is\n// the path /user/123 or whatever the value of id is.\nlet postWithId = fluent.path(id).post(json: User.self)\nlet user = try await postWithId.receive(json: User.self)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprosumma%2Fhttpfluent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprosumma%2Fhttpfluent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprosumma%2Fhttpfluent/lists"}