yada is a web library for Clojure, designed to support the creation of production services via HTTP.
It has the following features:
yada is a sibling library to bidi - whereas bidi is based on routes as data, yada is based on resources as data.
The user-manual for the latest (1.x) release is available at https://juxt.pro/yada and offline (see below).
The user-manual is also available as an e-book or PDF, at Leanpub.
Add the following dependency to your project.clj
or build.boot
file:
[yada "1.2.15"]
Typically, yada handlers are created from a configuation expressed in data.
(require '[yada.yada :as yada])
(yada/handler
{:methods
{:get
{:produces "text/html"
:response "<h1>Hello World!</h1>"}}})
This is a simple example, there are a lot more options in yada than can be expressed here, but the approach is the same. The data configuration can be hand-authored, or generated programmatically leading enabling creation of consistent APIs at an industrial scale.
yada requires the following :-
Support for other web-severs, such as undertow, are on the road-map.
If you want to ensure that your code will not break with future releases of yada, you should only use functions from the yada.yada
namespaces.
You are free to use other public functions in yada, but please be warned that these can and do change between releases.
By default, yada is batteries-included, bringing in a large number of dependencies.
However, a leaner version of yada is available which cuts out Swagger, swagger-ui, JSON (cheshire), Transit, buddy, core.async, SSE and other fat.
The following differences apply:
To use the lean (or any other) variant of yada, specify the
appropriate classifier in your project.clj
or build.boot
file:
[yada/lean "1.2.15"]
Although yada is a library, if you clone this repo you can run the documentation and examples from the REPL.
cd yada
lein repl
Once the REPL starts, type in and run the following :-
user> (dev)
dev> (go)
Now browse to http://localhost:8090.
Q. I'm migrating from a version before yada 1.1 and my async multipart and other uploads are not working, sometimes throwing NullPointerExceptions or other errors.
A. Either use yada's built-in yada.server function or make sure you have started aleph's server with the option raw-stream? :true
. Previous versions of yada left these settings up to the user but it's very important in yada 1.1 that raw-stream? is set.
yadarians mostly chat in the Slack channel plus there is also a dedicated Gitter channel channel
Also, there is a discussion group yada-discuss to discuss ideas.
Feel free to raise GitHub issues on this repository.
Pull requests are welcome. Please run the test suite and check that all tests pass prior to submission.
$ lein test
If you want to build and test your own version of yada, you need to be aware how to locally install your own version. Since yada is broken into multiple Maven jars, each with their own version declaration, there is a script that allows you to set the version to whatever you need it to be.
$ ./set-version 1.3.0-MS-SNAPSHOT
Rather than use lein install
, you should replace lein
with ./treelein
.
For example:
$ ./treelein install
This will install all the yada jars into your local Maven repository.
Thanks to the following people for inspiration, contributions, feedback and suggestions.
Also, see the dependency list. In particular, yada would certainly not exist without the considerable efforts of those behind the following libraries.
The MIT License (MIT)
Copyright © 2015-2016 JUXT LTD.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close