{"id":15930659,"url":"https://github.com/kimar/ktor-middleware","last_synced_at":"2025-04-03T14:19:05.625Z","repository":{"id":54963257,"uuid":"105637799","full_name":"kimar/Ktor-Middleware","owner":"kimar","description":"A dead-simple Middleware Implementation for the Ktor Web Framework","archived":false,"fork":false,"pushed_at":"2021-01-19T10:44:55.000Z","size":33,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T03:14:50.563Z","etag":null,"topics":["backend","kotlin","ktor","maven","middleware","webapp"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kimar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-03T10:10:11.000Z","updated_at":"2025-01-04T07:07:28.000Z","dependencies_parsed_at":"2022-08-14T07:31:15.644Z","dependency_job_id":null,"html_url":"https://github.com/kimar/Ktor-Middleware","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimar%2FKtor-Middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimar%2FKtor-Middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimar%2FKtor-Middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimar%2FKtor-Middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kimar","download_url":"https://codeload.github.com/kimar/Ktor-Middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247014518,"owners_count":20869376,"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":["backend","kotlin","ktor","maven","middleware","webapp"],"created_at":"2024-10-07T00:42:59.737Z","updated_at":"2025-04-03T14:19:05.589Z","avatar_url":"https://github.com/kimar.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ktor-Middleware\n\n## A dead-simple middleware for Kotlin/Ktor\n\n### Installation\n\n### pom.xml\n\n```java\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.github.kimar\u003c/groupId\u003e\n        \u003cartifactId\u003eKtor-Middleware\u003c/artifactId\u003e\n        \u003cversion\u003e0.2.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### build.gradle\n\n```java\ncompile 'com.github.kimar:Ktor-Middleware:0.2.2'\n```\n\n### Usage\n\n#### Inside your route handler\n\nLet's assume you've got an `upload` route you'd like to secure using `BearerAuthentication`, one way would be to install this routing using `Ktor-Middleware` which will then, in turn, automatically filter all failed middlewares and report and error accordingly, e.g.:\n\n```java\n\nfun Application.module() {\n\t...\n\tinstall(Routing) {\n\t\tupload(listOf(BearerAuthentication(\"secret_token\"))\n\t}\n}\n\nfun Routing.upload(middlewares: List\u003cMiddleware\u003cUnit, HttpStatus\u003e\u003e): Route {\n    return post(\"upload\") {\n\n        val eval = middlewares.evaluate(this)\n        when(eval.success) {\n            true -\u003e success(call)\n            else -\u003e call.respondText(eval.result!!.gsonify(), ContentType.Application.Json)\n        }\n    }\n}\n\nprivate fun success(call: ApplicationCall) {\n\t...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimar%2Fktor-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkimar%2Fktor-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimar%2Fktor-middleware/lists"}