Liking cljdoc? Tell your friends :D

active.data.http.rpc.reitit


context-routesclj

(context-routes context implementations)

Returns a reitit routes vector defining routes that implement the given rpcs. Use impl or impl-ext to specify the implementations. The opts parameter is the same as for [[reitit.ring/router]].

(context-routes my-api/context [(impl #'my-api/plus +)])

Important note: To use this, you need a transit parser middleware in your middleware chain, like muuntaja for example [https://github.com/metosin/reitit/blob/master/doc/ring/content_negotiation.md].

You can add this higher up, for example like this:

["" {:muuntaja muuntaja.core/instance
       :middleware [reitit.ring.middleware.muuntaja/format-middleware]}
 (context-routes ...)]

You will also need to add [[reitit.ring.middleware.parameters/parameters-middleware]] to you middlware chain. If you don't need it anywhere else in your application anyway, add it like this:

["" {:middleware [reitit.ring.middleware.parameters/parameters-middlware]}
 (context-routes ...)]
Returns a reitit routes vector defining routes that implement the
 given rpcs. Use [[impl]] or [[impl-ext]] to specify the
 implementations. The `opts` parameter is the same as for [[reitit.ring/router]].

```
(context-routes my-api/context [(impl #'my-api/plus +)])
```

Important note: To use this, you need a transit parser middleware in
your middleware chain, like muuntaja for example
[https://github.com/metosin/reitit/blob/master/doc/ring/content_negotiation.md].

You can add this higher up, for example like this:
```
["" {:muuntaja muuntaja.core/instance
       :middleware [reitit.ring.middleware.muuntaja/format-middleware]}
 (context-routes ...)]
```

You will also need to add
[[reitit.ring.middleware.parameters/parameters-middleware]] to you
middlware chain. If you don't need it anywhere else in your
application anyway, add it like this:

```
["" {:middleware [reitit.ring.middleware.parameters/parameters-middlware]}
 (context-routes ...)]
```
sourceraw docstring

implclj

(impl rpc-var handler)

Specifies an rpc implemtation as a function with the arguments and return value exaclty as declared in the rpc declaration via active.data.http.rpc/defn-rpc.

(impl #'my-api/plus +)
Specifies an rpc implemtation as a function with the arguments and
return value exaclty as declared in the rpc declaration via
  [[active.data.http.rpc/defn-rpc]].

  ```
  (impl #'my-api/plus +)
  ```
  
sourceraw docstring

impl-extclj

(impl-ext rpc-var spec)

Specifies an rpc implemtation as a ring handler spec, where the :handler takes a request map and returning a response map. The request map will contain an :args key, containing the list of arguments of the rpc call, and must return the rpc result as the :body in the response map.

(impl-ext #'my-api/plus
          {:handler (fn [req]
                      {:status 200 :body (apply + (:args req))})})
Specifies an rpc implemtation as a ring handler spec, where the
`:handler` takes a request map and returning a response map. The
request map will contain an `:args` key, containing the list of
arguments of the rpc call, and must return the rpc result as the
`:body` in the response map.

```
(impl-ext #'my-api/plus
          {:handler (fn [req]
                      {:status 200 :body (apply + (:args req))})})
```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close