{"id":15953382,"url":"https://github.com/andrewvc/noir-async","last_synced_at":"2025-03-16T07:31:46.612Z","repository":{"id":2108560,"uuid":"3050242","full_name":"andrewvc/noir-async","owner":"andrewvc","description":"Seamless, concise, async webservices for clojure.","archived":false,"fork":false,"pushed_at":"2012-09-09T18:53:21.000Z","size":246,"stargazers_count":98,"open_issues_count":1,"forks_count":1,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-15T23:51:14.362Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://andrewvc.github.com/noir-async/","language":"Clojure","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/andrewvc.png","metadata":{"files":{"readme":"README.markdown","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":"2011-12-26T04:18:48.000Z","updated_at":"2025-03-14T03:16:03.000Z","dependencies_parsed_at":"2022-08-25T10:31:05.343Z","dependency_job_id":null,"html_url":"https://github.com/andrewvc/noir-async","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/andrewvc%2Fnoir-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewvc%2Fnoir-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewvc%2Fnoir-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewvc%2Fnoir-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewvc","download_url":"https://codeload.github.com/andrewvc/noir-async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841127,"owners_count":20356440,"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-10-07T13:12:13.872Z","updated_at":"2025-03-16T07:31:46.227Z","avatar_url":"https://github.com/andrewvc.png","language":"Clojure","readme":"# noir-async [![Build Status](https://secure.travis-ci.org/andrewvc/noir-async.png?branch=master)](http://travis-ci.org/andrewvc/noir-async)\n\n## Seamless, concise, async webservices for clojure.\n\nnoir-async integrates the [noir](https://github.com/ibdknox/noir) web framework with the [aleph](https://github.com/ztellman/aleph) async library with minimal syntax. With noir-async you can create well organized webapps, with both synchronous and asynchronous logic, and multiple asynchronous endpoints.\n\n##  Getting Started\n\n1. Add `[noir-async 1.1.0-beta7]` to your project.clj\n1. Use the custom [server.clj](#server-setup)\n1. Follow the examples below\n1. Read the [full API docs](http://andrewvc.github.com/noir-async/autodoc/) for more examples.\n\nHere's an example route that responds in one shot:\n\n```clojure\n; Note, same syntax as noir's defpage, but with \"conn\" parameter\n(defpage-async \"/route\" [] conn\n  (async-push conn {:status 404 :body \"Couldn't find it!\"}))\n```\n\nThis is an example route that handles a websocket:\n\n```clojure\n(defpage-async \"/echo\" [] conn\n  (on-receive conn (fn [m] (async-push conn m))))\n```\n\nHere's an example of responding in a chunked fashion:\n\n```clojure\n(defpage-async \"/always-chunky\" [] conn\n  ;; Sending the header explicitly indicates a chunked response\n  (async-push conn {:status 200 :chunked true})\n  (async-push conn \"chunk one\")\n  (async-push conn \"chunk two\")\n  (close-connection conn))\n```\n\nReading request bodies with aleph can be a little odd, so that interface is sugared:\n\n```clojure\n(defpage-async \"/some-route\" {} conn\n  ;; You can also retrieve the body as a ByteBuffer. See full docs for details\n  (async-push (str \"Received body:\" (request-body-str conn))))\n```\n\nSince it uses an identical interface for both websockets\nand regular HTTP, if you want to handle them differently be\nsure to use the websocket? and regular? functions to discern them.\n\n## Server Setup\n\nIn your server.clj, you'll want to use aleph as a server explicitly.\nBe sure to replace noir-async-chat with the appropriate namespace.\n\n```clojure\n(ns noir-async-chat.server\n  (:use aleph.http\n        noir.core\n        lamina.core)\n  (:require\n    [noir.server :as nr-server] ))\n\n(nr-server/load-views \"src/noir_async_chat/views/\")\n\n(defn -main [\u0026 m]\n  (let [mode (keyword (or (first m) :dev))\n        port (Integer. (get (System/getenv) \"PORT\" \"3000\"))\n        noir-handler (nr-server/gen-handler {:mode mode})]\n    (start-http-server\n      (wrap-ring-handler noir-handler)\n      {:port port :websocket true})))\n```\n\n## Full Docs\n\n[Full API Docs](http://andrewvc.github.com/noir-async/autodoc/) for more examples.\n\n## Apps Using noir-async\n\n[engulf](https://github.com/andrewvc/engulf)\n[noir-async-chat](https://github.com/andrewvc/noir-async-chat)\n\n## License\n\nCopyright (C) 2011 Andrew Cholakian\n\nDistributed under the Eclipse Public License, the same as Clojure.\n\n\n","funding_links":[],"categories":["\u003ca name=\"Clojure\"\u003e\u003c/a\u003eClojure"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewvc%2Fnoir-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewvc%2Fnoir-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewvc%2Fnoir-async/lists"}