{"id":16538014,"url":"https://github.com/multicatch/ksockserver","last_synced_at":"2025-10-28T15:32:17.591Z","repository":{"id":45158605,"uuid":"262004510","full_name":"multicatch/ksockserver","owner":"multicatch","description":"A framework for building servers written in Kotlin JVM","archived":false,"fork":false,"pushed_at":"2022-01-04T16:44:26.000Z","size":98,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T05:11:27.659Z","etag":null,"topics":["socket","tcp"],"latest_commit_sha":null,"homepage":"","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/multicatch.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}},"created_at":"2020-05-07T09:16:59.000Z","updated_at":"2021-12-18T18:30:05.000Z","dependencies_parsed_at":"2022-09-04T10:40:20.895Z","dependency_job_id":null,"html_url":"https://github.com/multicatch/ksockserver","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/multicatch%2Fksockserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multicatch%2Fksockserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multicatch%2Fksockserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multicatch%2Fksockserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multicatch","download_url":"https://codeload.github.com/multicatch/ksockserver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241739430,"owners_count":20012103,"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":["socket","tcp"],"created_at":"2024-10-11T18:44:14.687Z","updated_at":"2025-10-28T15:32:12.546Z","avatar_url":"https://github.com/multicatch.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ksockserver\n\nA little HTTP server in Kotlin\n\n### Description\n\nThis project aims to develop a simple, but extensible framework for building\nTCP servers of any purpose. It comes with HTTP/1.1 by default, but it can be used with\nany protocol, as long as the support for it is implemented.\n\n### Features\n\nServer features:\n* Event-based processing (based on _Interruptible Tasks_)\n* Secure TLS Sockets (with HTTPS)\n* Slowloris-proof and handles many connections well\n\nHTTP implementation features:\n* GZIP response compression\n* HTTP Proxy\n* Static resources support\n* URL aliasing support\n* Exception Mappers for global exception mapping support\n\n### Sample configuration \n\nSee [Example.kt](ksockserver-example/src/main/java/io/github/multicatch/ksock/example/Example.kt)\n\n```kotlin\nfun main() {\n    // bind plain TCP on 8080, use HTTP\n    bindTCP(port = 8080, protocol = Http) {\n        // use HTTP 1.1 on this port\n        useHttp11()\n        // use GZIP\n        withResponseWriter(GZipResponseWriter())\n\n        // configure /* mapping\n        url(index(\"/\")) {\n            // a static index of classpath resources\n            staticIndex(\"classpath:/\")\n        }\n\n        // configure /example mapping\n        url(exact(\"/example\")) {\n            // a static page\n            staticPage(\"classpath:/index.html\")\n        }\n   \n        // configure /proxy mapping\n        url(exact(\"/proxy\")) {\n            // a proxy of https://httpbin.org\n            proxy(\"https://httpbin.org/\")\n        }\n\n        // make / an alias of /index.html\n        alias(exact(\"/\") to \"/index.html\")\n    }.start() // start server on port 8080\n\n    // bind secure TCP on 8443, use HTTP and a self signed certificate\n    bindSecureTCP(\n            port = 8443,\n            protocol = Http,\n            serverCertificate = selfSignedCertificate()\n    ) {\n        // use HTTP 1.1 on this port\n        useHttp11()\n\n        // configure /* mapping\n        url(index(\"/\")) {\n            // a static index of classpath resources\n            staticIndex(\"classpath:/\")\n        }\n\n        // configure /proxy mapping\n        url(exact(\"/proxy\")) {\n            // a proxy of https://httpbin.org\n            proxy(\"https://httpbin.org/\")\n        }\n\n        // make / an alias of /index.html\n        alias(exact(\"/\") to \"/index.html\")\n    }.start() // start server on port 8443\n}\n```\n\n### Project Modules\n\n#### ksockserver-example\nThis is an example usage of the ksockserver. It contains one Kotlin file, which starts the application \non ports 8080 and 8443 (SSL). There are the following endpoints available:\n* `/` or `/index.html` - a sample HTML file\n* `/proxy` - a proxy to https://httpbin.org/\n* `/example` (8080 only) - a static resource (HTML file)\n\n#### ksockserver-dispatcher\n\nThis module contains the logic of managing the socket and handling connections. There are socket configuration classes \nand dispatchers for plain TCP and secure TCP sockets.\n\n#### ksockserver-http-core\n\nThe `ksockserver-http-core` module contains the base models and interfaces used in HTTP-related libraries, and it also\ncontains a few common helper functions.\n\n#### ksockserver-http-server\n\nThis module relies on `ksockserver-http-core` and `ksockserver-dispatcher` and it contains the logic of handling \nreading of HTTP requests, mapping URLs to resource handlers and writing HTTP responses. It also handles the exceptions\nduring request processing and maps them according to registered ExceptionMappers\n\n#### ksockserver-static-pages\n\nIn this module there is logic that handles reading files and serving them as static resources. It is meant to be used\nwith a `ksockserver-http-server`.\n\n#### ksockserver-http-gzip\n\nThis little module enables GZip compression algorithm in HTTP responses.\n\n#### ksockserver-http-proxy\n\nThis module is used to configure a URL mapping as a proxy of another HTTP(S) application.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmulticatch%2Fksockserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmulticatch%2Fksockserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmulticatch%2Fksockserver/lists"}