A Clojure application designed to get you quickly ramped up with a running Web Server that exposes a dynamic CRUD rest api to your mongo database.
This is a great tool for prototyping backend json data for front end web applications.
This application does not contain any security and runs on http://localhost:8080 it also uses the default mongo connection properties "127.0.0.1" port 27017
from the command line
lein repl
user=> (load "cjweb/core")
user=> (ns cjweb.core)
cjweb.core=> (start-server)
You can now browse to your application
The below curl will create a database called library and a collection called book.
It will also store a book record represented by the json in the book collection of your mongo db.
from the command line
Mac
curl -d '{"title":"Learning clojure","isbn":"3424","author":"Alex Mcknight"}' -H "Content-Type: application/json" -X POST http://localhost:8080/mongo/library/book
Windows
curl -d "{\"title\":\"Learning clojure\",\"isbn\":\"3424\",\"author\":\"Alex Mcknight\"}" -H "Content-Type: application/json" -X POST http://localhost:8080/mongo/library/book
optional parameters
page = what page of the data should we retrieve
rows = how many records of the data should we retrieve
q = the valid mongo json query
curl -H "Content-Type: application/json" -X GET http://localhost:8080/mongo/library/book?page=1&rows=10&q={"title":{"bw":"Learn"}}
Update is the same as save except that an id must be included that references the record in question
curl -d '{"_id":"ID_OF_THE_RECORD",title":"Learning clojure","isbn":"3424","author":"Alexander Mcknight"}' -H "Content-Type: application/json"
curl -H "Content-Type: application/json" -X GET http://localhost:8080/mongo/library/book/ID_OF_THE_RECORD
curl -H "Content-Type: application/json" -X DELETE http://localhost:8080/mongo/library/book/ID_OF_THE_RECORD
from the command line
lein test
Copyright © 2019
Distributed under the Eclipse Public License (the same as Clojure) or the Apache Public License 2.0.