{"id":15004052,"url":"https://github.com/alephao/swift-http-types-htmx","last_synced_at":"2025-07-02T20:33:19.562Z","repository":{"id":257155294,"uuid":"857357461","full_name":"alephao/swift-http-types-htmx","owner":"alephao","description":"swift-http-types extensions for htmx","archived":false,"fork":false,"pushed_at":"2024-09-18T23:03:59.000Z","size":416,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-27T05:58:24.101Z","etag":null,"topics":["htmx","server","swift","swift-http-types"],"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/alephao.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}},"created_at":"2024-09-14T12:49:23.000Z","updated_at":"2024-11-21T17:52:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"196a2633-2dbe-45e2-950a-e5aedcf35b62","html_url":"https://github.com/alephao/swift-http-types-htmx","commit_stats":null,"previous_names":["alephao/swift-http-types-htmx"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/alephao/swift-http-types-htmx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alephao%2Fswift-http-types-htmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alephao%2Fswift-http-types-htmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alephao%2Fswift-http-types-htmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alephao%2Fswift-http-types-htmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alephao","download_url":"https://codeload.github.com/alephao/swift-http-types-htmx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alephao%2Fswift-http-types-htmx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263210695,"owners_count":23431182,"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":["htmx","server","swift","swift-http-types"],"created_at":"2024-09-24T19:00:44.171Z","updated_at":"2025-07-02T20:33:19.532Z","avatar_url":"https://github.com/alephao.png","language":"Swift","funding_links":[],"categories":["Tools"],"sub_categories":[],"readme":"# swift-http-types-htmx\n[![CI](https://github.com/alephao/swift-http-types-htmx/actions/workflows/ci.yml/badge.svg)](https://github.com/alephao/swift-http-types-htmx/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/alephao/swift-http-types-htmx/graph/badge.svg?token=Ef5FszDA3Y)](https://codecov.io/gh/alephao/swift-http-types-htmx)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Falephao%2Fswift-http-types-htmx%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/alephao/swift-http-types-htmx)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Falephao%2Fswift-http-types-htmx%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/alephao/swift-http-types-htmx)\n\n[HTMX](https://htmx.org) extensions for [`apple/swift-http-types`](https://github.com/apple/swift-http-types).\n\nThe package provides extensions for:\n\n- `HTTPField.Name` initializers, e.g.: `HTTPField.Name.hxLocation` = `'HX-Location'`\n- `HTTPField` initializers e.g.: `HTTPField.hxLocation('/path')` = `HX-Location: /path`\n- `HTTPFields` getters e.g.: `HTTPFields.hxRequest: Bool`, `HTTPFields.hxLocation: String?`\n\nIt also provides HTMX documentation in-code:\n\n![](/Resources/ss-xcode-doc.png)\n\n### Usage\n\n```swift\nimport HTTPTypes \nimport HTTPTypesHtmx\n\n// Creating HTTPFields\n\nlet headersViaArray = HTTPFields([\n  .hxRetarget(\"#myDiv\"),\n  .hxReswap(.outerHTML),\n])\n\nlet headersViaDictionary: HTTPFields = [\n  .hxRetarget: \"#myDiv\",\n  .hxReswap: HxSwap.outerHTML,\n] \n\n// Getting values from HTTPFields\nlet exampleRequestHeaders = HTTPFields([\n  .hxBoosted(),\n  .hxRequest(),\n  .hxTarget(id: \"myDiv\")\n])\n\nrequestHeaders.hxBoosted // true\nrequestHeaders.hxRequest // true\nrequestHeaders.hxTarget  // \"myDiv\"\n```\n\n## Examples\n\nThere is an [example project](Examples) of a server using the [Hummingbird Framework](http://github.com/hummingbird-project/hummingbird) with a few exampels on how to use HTMX response headers to drive the application.\n\nThere are also tests for all handlers, demonstrating how this library can be used to mock HTMX requests for testing purposes.\n\n## Installation\n\nAdd the dependency to Package.swift\n\n```swift\ndependencies: [\n  .package(url: \"https://github.com/alephao/swift-http-types-htmx.git\", from: \"0.3.0\")\n],\n```\n\nAdd the products you want to use to the target dependencies\n\n```swift\n.target(\n  name: \"MyTarget\",\n  dependencies: [\n    .product(name: \"HTTPTypesHtmx\", package: \"swift-htmx\"),\n  ]\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falephao%2Fswift-http-types-htmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falephao%2Fswift-http-types-htmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falephao%2Fswift-http-types-htmx/lists"}