Liking cljdoc? Tell your friends :D

Action Literals

This page describes the action literals and their parameters. For the full scoop, you should definitely look at src/com/cognitect/vase/literals.clj.

All the literals can be chained together in a single route, except for #vase/respond and #vase/redirect. To chain literals, put them in a vector.

#vase/respond

Immediately send an HTTP response. This cannot be chained together with any other literals.

ParamMeaning
:nameName of the interceptor. Required.
:paramsSymbols to bind from :params.
:headersAny extra headers to merge with the defaults.
:edn-coerceSymbols that should be parsed as EDN data before binding.
:bodyAn expression that produces the body of the response
:statusThe HTTP status code to return

#vase/redirect

Immediately send a 302 redirect response to the client. This cannot be chained together with any other literals.

ParamMeaning
:nameName of the interceptor. Required.
:paramsSymbols to bind from :params.
:headersAny extra headers to merge with the defaults.
:bodyThe body of the response
:statusThe HTTP status code to return
:urlAn expression that produces a URL. This will be the "Location" header sent to the client.

#vase/validate

Apply specs to the inputs.

ParamMeaning
:nameName of the interceptor. Required.
:paramsSymbols to bind from :params.
:headersAny extra headers to merge with the defaults.
:specThe spec to apply. Must be registered before this action executes.
:request-params-pathInstead of locating parameters directly in the :request, use this path to navigate through nested maps.

If validate is the last interceptor or if any of the specs fail, it will generate a response.

#vase/conform

Apply specs to data on the context, reattaching the conformed data to the context.

ParamMeaining
:nameName of the interceptor.
:fromThe context map key where data will be found.
:specThe spec to apply. Must be registered before this action executes.
:toThe context map key where the conformed data will be attached.
:explain-toThe context map key where explain-data will be attached if the data fails the spec. Defaults to :com.cognitect.vase.actions/explain-data.

#vase/query

Run a datalog query and return the results as JSON

ParamMeaning
:nameName of the interceptor. Required.
:paramsSymbols to bind from :params.
:headersAny extra headers to merge with the defaults.
:edn-coerceSymbols that should be parsed as EDN data before binding.
:queryA datalog query expression. Has access to symbols from params, in order, in the :in clause.
:constantsAdditional values to be passed to the query, following all the parameters.
:toThe context map key where the query results will be attached. Defaults to :com.cognitect.vase.actions/query-data

If this is the last interceptor in the chain, it generates a response.

If this is not the last interceptor in the chain, it attaches the query results to the context map at the :to key

#vase/transact

Execute a Datomic transaction. Return the results (the tx-result) as JSON. The new database value will be used for any subsequent datalog queries.

ParamMeaning
:nameName of the interceptor. Required.
:propertiesWhitelist of parameters to accept from the client
:headersAny extra headers to merge with the defaults.
:db-opEither :vase/assert-entity or :vase/retract-entity. Defaults to :vase/assert-entity.
:toThe context map key where the transaction results will be attached. Defaults to :com.cognitect.vase.actions/transact-data

If this is the last interceptor in the chain, it generates a response.

If this is not the last interceptor in the chain, it attaches the transaction result to the context map at the :to key.

#vase/intercept

Define an interceptor, given code in the descriptor file. The form immediately after the literal is used directly as the interceptor body.

Can you improve this documentation? These fine people already did:
Michael Nygard & Donald Ball
Edit on GitHub

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

× close