{"id":23390663,"url":"https://github.com/hazer/domehttp","last_synced_at":"2025-04-08T14:35:06.841Z","repository":{"id":69466697,"uuid":"190490922","full_name":"Hazer/DomeHTTP","owner":"Hazer","description":"Kotlin Multiplatform HTTP Client","archived":false,"fork":false,"pushed_at":"2019-06-11T01:06:39.000Z","size":199,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T10:55:55.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/Hazer.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":"2019-06-06T01:03:56.000Z","updated_at":"2021-05-03T14:16:02.000Z","dependencies_parsed_at":"2023-06-25T22:13:52.699Z","dependency_job_id":null,"html_url":"https://github.com/Hazer/DomeHTTP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hazer%2FDomeHTTP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hazer%2FDomeHTTP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hazer%2FDomeHTTP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hazer%2FDomeHTTP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hazer","download_url":"https://codeload.github.com/Hazer/DomeHTTP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247861615,"owners_count":21008532,"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":[],"created_at":"2024-12-22T03:42:19.875Z","updated_at":"2025-04-08T14:35:06.835Z","avatar_url":"https://github.com/Hazer.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DomeHTTP Client (WIP) [ ![Download](https://api.bintray.com/packages/hazer/maven/DomeHTTP/images/download.svg) ](https://bintray.com/hazer/maven/DomeHTTP/_latestVersion)\n\nThis project is a Kotlin Multiplatform HTTP Client, totally work-in-progress, implementation is not optimal, code not tested, API not final.\n\n## Goals\n* Coroutines-based\n* Small dependencies and almost reflection-free, `inline` the most we can\n    (small binary size and low methods count because \"Android 64k method limit\")\n* Make it easy to replace the engine, if needed\n* Someday iOS target will work flawlessly\n\n## Challenges\n* Multi-threading in Native\n* Reflection API, maybe compile-time generated, in Native and JS\n\n## Installation\n\n```\nrepositories {\n    maven { url \"https://dl.bintray.com/hazer/maven\" }\n}\n\n// Common Module\nimplementation \"io.vithor.libs:dome-http:$last_version\"\n\n// Android Module\nimplementation \"io.vithor.libs:dome-http-android:$last_version\"\n\n// iOS Module\nimplementation \"io.vithor.libs:dome-http-ios:$last_version\" // x86/Simulator\nimplementation \"io.vithor.libs:dome-http-iosArm32:$last_version\"\nimplementation \"io.vithor.libs:dome-http-iosArm64:$last_version\"\n\n// JVM Module\nimplementation \"io.vithor.libs:dome-http-jvm:$last_version\"\n```\n\n## Usages\nFirst you need to declare the Client configuration using default provided engines (you can create your own engine):\n\n```kotlin\nval dome = DomeClient(engine = OkHttpEngine() /* or NSUrlSessionEngine() */) {\n    timeouts {\n        connect = 30.seconds\n        read = 30.seconds\n        write = 30.seconds\n    }\n\n    serialization(KotlinxSerializer(strict = true)) {\n        // Unfortunately, right now to work also in iOS, we need to declare all Top Serializers manually.\n        register(Todo.serializer())\n        register(TodoCreate.serializer())\n    }\n}\n```\n\nThen we can make requests as:\n\n```kotlin\n// GET request\nval todo = dome.get\u003cTodo\u003e(\"https://jsonplaceholder.typicode.com/todos/1\").await(Dispatchers.IO)\n```\n```kotlin\n// GET request with configurations\nval todos: List\u003cTodo\u003e = dome.get\u003cTodo\u003e(\"https://jsonplaceholder.typicode.com/todos\") {\n    headers += mapOf(\n        \"X-Header-Name\" to \"header value\"\n    )\n\n    addHeader(\"X-Another-Header\", \"Another value\")\n\n    params = listOf(\n        \"excerpt\" to \"yes\",\n        \"user\" to \"Vithorio\",\n        \"language\" to \"pt-BR\"\n    )\n\n    addQueryParam(\"another-param\", \"Mage\")\n\n}.asList\u003cTodo\u003e().await()\n // Because we have no Reflection API in iOS, we cannot write only dome.get\u003cList\u003cTodo\u003e\u003e and work with Kotlinx.Serialization, that's why `asList` exists\n```\n```kotlin\n// POST request with Json\nval todoCreated = dome.post\u003cTodoCreate\u003e(\"https://jsonplaceholder.typicode.com/todos\") {\n    jsonOf(\n        TodoCreate(\n            userId = 1,\n            title = \"Just a POST test\",\n            body = \"This is what is missing to do\"\n        )\n    )\n}.await()\n```\n```kotlin\n// POST request with form url encoded\nval todoCreated = dome.post\u003cTodoCreate\u003e(\"https://jsonplaceholder.typicode.com/todos\") {\n    formOf(\n        \"userId\" to \"1\",\n        \"title\" to \"Just a POST test\",\n        \"body\" to \"This is what is missing to do\"\n    )\n    // or\n    form(\n        listOf(\n            \"userId\" to \"1\",\n            \"title\" to \"Just a POST test\",\n            \"body\" to \"This is what is missing to do\"\n        )\n    )\n}.await()\n```\n\n## Credits\nThis project takes a lot of inspiration from [ktorio/ktor](https://github.com/ktorio/ktor) and [rybalkinsd/kohttp](https://github.com/rybalkinsd/kohttp).\nI started building this project because Ktor Client in Android was heavy, so I made this initially as a study project and as an alternative with lower footprint.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazer%2Fdomehttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhazer%2Fdomehttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazer%2Fdomehttp/lists"}