{"id":31943288,"url":"https://github.com/luminus-framework/luminus-jetty","last_synced_at":"2025-10-14T09:50:49.622Z","repository":{"id":3687994,"uuid":"49251080","full_name":"luminus-framework/luminus-jetty","owner":"luminus-framework","description":"Jetty adapter for Luminus","archived":false,"fork":false,"pushed_at":"2022-01-08T13:59:28.000Z","size":41,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-03T08:52:59.230Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luminus-framework.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":"2016-01-08T05:12:23.000Z","updated_at":"2023-03-03T08:59:24.000Z","dependencies_parsed_at":"2022-08-06T14:15:18.060Z","dependency_job_id":null,"html_url":"https://github.com/luminus-framework/luminus-jetty","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luminus-framework/luminus-jetty","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fluminus-jetty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fluminus-jetty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fluminus-jetty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fluminus-jetty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luminus-framework","download_url":"https://codeload.github.com/luminus-framework/luminus-jetty/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fluminus-jetty/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018554,"owners_count":26086404,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-10-14T09:50:23.928Z","updated_at":"2025-10-14T09:50:49.616Z","avatar_url":"https://github.com/luminus-framework.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# luminus-jetty\n\n[![Clojars Project](https://img.shields.io/clojars/v/luminus-jetty.svg)](https://clojars.org/luminus-jetty)\n\nJetty HTTP adapter for Luminus\n\n### HTTP handler\n\n```clojure\n(ns myapp.core\n  (:require\n   [luminus.ws :as ws]\n   [luminus.http-server :as http]))\n\n(defn http-handler [request]\n  {:status 200\n   :headers {\"Content-Type\" \"text/plain\"}\n   :body (:remote-addr request)})\n\n(http/start\n {:handler http-handler\n  :port 3000})\n```\n\n### WS handler\n\n```clojure\n(ns myapp.core\n  (:require\n   [luminus.ws :as ws]\n   [luminus.http-server :as http]\n   [clojure.tools.logging :as log]))\n\n;; a handler can be specified using a map\n(def ws-handler-a\n  {:on-connect           (fn [ws]\n                           (log/info \"WS connect\" ws))\n   :on-error             (fn [ws e]\n                           (log/info \"WS error\" e))\n   :on-text              (fn [ws text]\n                           (log/info \"text:\" text)\n                           (ws/send! ws text))\n   :on-close             (fn [ws status-code reason]\n                           (log/info \"WS close\" reason))\n   :on-bytes             (fn [ws bytes offset len]\n                           (log/info \"WS bytes\" bytes))})\n\n;; alternatively you can provide a function that accepts a\n;; Ring request map to initialize the websocket connection\n;;\n;; websocket upgrade headers like subprotocol and extensions\n;; are available from the `req` via `(:websocket-subprotocols req)`\n;; and `(:websocket-extensions req)`.\n\n(def ws-handler-b\n  (fn [req]\n    {:on-connect (fn [\u0026 args]\n                   (log/info \"WS connect\" args))\n     :on-error   (fn [\u0026 args]\n                   (log/info \"WS error\" args))\n     :on-text    (fn [ws text]\n                   (log/info \"text:\" text)\n                   (ws/send! ws text))\n     :on-close   (fn [\u0026 args]\n                   (log/info \"WS close\" args))\n     :on-bytes   (fn [\u0026 args]\n                   (log/info \"WS bytes\" args))})})\n\n(defn web-handler [request]\n  (if (ws/ws-upgrade-request? request)\n    ;; websocket upgrade request\n    (ws/ws-upgrade-response ws-handler-a)\n    ;; normal http request\n    {:status 200\n     :headers {\"Content-Type\" \"text/plain\"}\n     :body (:remote-addr request)}))\n\n;;create a single WS handler\n(http/start\n {:handler web-handler\n  :port 3000})\n```\n\nWebSocketProtocol allows you to read and write data on the `ws` value:\n\n* (send! ws msg)\n* (send! ws msg callback)\n* (close! ws)\n* (remote-addr ws)\n* (idle-timeout! ws timeout)\n\nNotice that we support different type of msg:\n\n* **byte[]** and **ByteBuffer**: send binary websocket message\n* **String** and other Object: send text websocket message\n* **(fn [ws])** (clojure function): Custom function you can operate on\n  Jetty's [RemoteEndpoint](http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/websocket/api/RemoteEndpoint.html)\n\nA callback can also be specified for `send!`:\n\n```clojure\n(send! ws msg {:write-failed (fn [throwable]) :write-success (fn [])})\n```\n\nA callback is a map where keys `:write-failed` and `:write-success` are optional.\n\n### Js client example\n\n```javascript\nvar websocket = new WebSocket(\"ws://localhost:3000/ws/\");\n\nwebsocket.onopen = function (evt) { console.log(\"socket open\"); };\nwebsocket.onclose = function (evt) { console.log(\"socket close\"); };\nwebsocket.onmessage = function (evt) { console.log(\"socket message: \" + evt.data); };\nwebsocket.onerror = function (evt) { websocket.send(\"message\"); };\n```\n\n### attribution\n\nThis library is based on\n[ring-jetty9-adapter](https://github.com/sunng87/ring-jetty9-adapter)\nwhich provides a Jetty ring adapter based on Jetty 10, with additional\nwebsocket support.\n\n## License\n\nCopyright © 2016 Dmitri Sotnikov\n\nDistributed under the Eclipse Public License either version 1.0 or (at your option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluminus-framework%2Fluminus-jetty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluminus-framework%2Fluminus-jetty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluminus-framework%2Fluminus-jetty/lists"}