Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theasp/macchiato-core-async
Core.async ring handler support for Macchiato
https://github.com/theasp/macchiato-core-async
async clojurescript macchiato macchiato-framework
Last synced: 13 days ago
JSON representation
Core.async ring handler support for Macchiato
- Host: GitHub
- URL: https://github.com/theasp/macchiato-core-async
- Owner: theasp
- License: mit
- Created: 2017-07-17T18:55:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-19T19:40:46.000Z (almost 7 years ago)
- Last Synced: 2024-11-10T14:12:19.669Z (2 months ago)
- Topics: async, clojurescript, macchiato, macchiato-framework
- Language: Clojure
- Size: 21.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CircleCI](https://circleci.com/gh/theasp/macchiato-core-async.svg?style=svg)](https://circleci.com/gh/theasp/macchiato-core-async)
[![Clojars Project](https://img.shields.io/clojars/v/ca.gt0.theasp/macchiato-core-async.svg)](https://clojars.org/ca.gt0.theasp/macchiato-core-async)A library for using [`core.async`](https://github.com/clojure/core.async/) with the [Macchiato Framework](https://macchiato-framework.github.io/).
# Example
```clojure
(ns example
(:require-macros
[cljs.core.async.macros :refer [go go-loop]]
[hiccups.core :as hiccups :refer [html]])
(:require
[ca.gt0.theasp.macchiato-core-async :as m-async]
[macchiato.server :as http]
[macchiato.middleware.defaults :as defaults]
[macchiato.middleware.restful-format :as restful-format]
[macchiato.middleware.resource :as resource]
[macchiato.util.response :as r]
[bidi.bidi :as bidi]
[bidi.ring :as bidi-ring]
[taoensso.timbre :as timbre
:refer-macros (tracef debugf infof warnf errorf)]))(defn not-found [req]
(-> [:html [:body [:h1 "404" ]]]
(html)
(r/ok))))(defn index-page [req]
(go
(-> [:html [:body [:p "Hi" ]]]
(html)
(r/ok))))
(def handlers {:index-page index-page
:not-found not-found})(def routes ["/" index-page])
(def handler (-> (bidi-ring/make-handler routes #(get handlers (:not-found handlers))
(m-async/wrap-async)
(restful-format/wrap-restful-format {:keywordize? true})
(resource/wrap-resource "resources/public")
(defaults/wrap-defaults {}))))(http/start {:handler handler
:host host
:port port
:on-success #(infof "HTTP server listening on %s:%s" host port)})
```