Fork me on GitHub
#datomic
<
2024-02-01
>
itaied10:02:00

Datomic ions: what are the use cases for http direct? can I invoke only a single function? At first I thought of it as a kind of webserver router

cch113:02:40

Bring your own router. Pretty much any ring-compatible router will work.

cch113:02:49

The configured function acts as the handler/entry point to your middleware/router/controllers stack. Alternatively, you can use something like pedestal without much effort. I'm using https://github.com/lambda-toolshed/papillon with a small adapter function.

itaied13:02:21

i don't know these tools, but i guess they route reqs based on the body of the content?

cch113:02:10

ring is a Clojure standard for stitching together middleware and handlers into a single composed handler for processing HTTP requests. Routing+dispatching is typically the innermost component of the handler and there are many pluggable routing solutions in the ring world (reitet, compojure, bidi, janus, etc). Alternatively, papillon, sippari and pedestal all define a more general model of composing functionality into a single function that can service HTTP requests. They too can use the same routers (generally) without much or any adaptation.

cch113:02:04

Both the ring middleware and interceptor model (of papillon/pedestal/sieppari) can work in Ions and, more commonly, processing http requests from and in-process server like jetty.

cch113:02:01

In any case, routing is almost always done on the path of the HTTP request, not on the body. Sometimes the HTTP method is considered too (compojure for sure used to do this).

itaied13:02:16

thank you, ill read more about it

silian19:02:01

@U057T406Y15 You may find this helpful https://ericnormand.me/guide/clojure-web-tutorial It is long but excellent!

🙌 1