{"id":16895818,"url":"https://github.com/bnorm/ktor-retrofit","last_synced_at":"2025-06-23T17:05:51.820Z","repository":{"id":57717919,"uuid":"150803162","full_name":"bnorm/ktor-retrofit","owner":"bnorm","description":"Turns a Retrofit service interface into Ktor routing","archived":false,"fork":false,"pushed_at":"2020-03-04T02:24:54.000Z","size":107,"stargazers_count":131,"open_issues_count":1,"forks_count":7,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-27T19:21:25.818Z","etag":null,"topics":["kotlin","ktor","ktor-framework","retrofit","retrofit2"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bnorm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-28T23:10:01.000Z","updated_at":"2025-02-03T05:54:52.000Z","dependencies_parsed_at":"2022-08-24T07:20:19.483Z","dependency_job_id":null,"html_url":"https://github.com/bnorm/ktor-retrofit","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/bnorm%2Fktor-retrofit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fktor-retrofit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fktor-retrofit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fktor-retrofit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnorm","download_url":"https://codeload.github.com/bnorm/ktor-retrofit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847061,"owners_count":20357317,"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":["kotlin","ktor","ktor-framework","retrofit","retrofit2"],"created_at":"2024-10-13T17:26:25.653Z","updated_at":"2025-03-17T06:31:53.162Z","avatar_url":"https://github.com/bnorm.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ktor-retrofit\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.bnorm.ktor.retrofit/ktor-retrofit/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.bnorm.ktor.retrofit/ktor-retrofit)\n\nTurns a Retrofit service interface into Ktor routing. Very early stage \nprototype.\n\nYou use Retrofit on the client side to access the end points of your server,\nwhy not use that same interface to define the routings? The idea is to use an\nimplementation of the interface and add it to Ktor routing which will\ndynamically construct sub-routings from the annotations and call the\nimplementation when the end point is accessed.\n\n## Example\n\n```kotlin\ninterface Service {\n  @GET(\"string\")\n  suspend fun getAll(): List\u003cString\u003e\n\n  @GET(\"string/{id}\")\n  suspend fun getSingle(@Path(\"id\") id: Long): String\n}\n\nfun Application.module() {\n  install(ContentNegotiation) {\n    jackson { }\n  }\n\n  val service = object : Service {\n    override suspend fun getAll(): List\u003cString\u003e {\n      return listOf(\"first\", \"second\")\n    }\n\n    override suspend fun getSingle(id: Long): String {\n      return when (id) {\n        0L -\u003e \"first\"\n        1L -\u003e \"second\"\n        else -\u003e throw IndexOutOfBoundsException(\"id=$id\")\n      }\n    }\n  }\n  \n  routing { \n    route(\"api\") {\n      retrofitService(service = service)\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnorm%2Fktor-retrofit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnorm%2Fktor-retrofit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnorm%2Fktor-retrofit/lists"}