Simple Web CRUD using Clojure and PostgreSQL
SQL:
CREATE DATABASE produto;
CREATE TABLE items (
id SERIAL PRIMARY KEY,
title VARCHAR(255),
description VARCHAR(255)
);
$ clone git@github.com:Ujs74wiop6/api-clojure.gitFirst of all, fill in your Postgres information
$ /api-clojure/src/crud/repository/migrations.clj
(def db {:dbtype ""
:dbname "produto"
:user ""
:password ""})
Downloading the dependencies
$ lein depsRunning the project
$ lein runCreating the product:
curl -X POST localhost:3000/produto -H "Content-Type: application/json" -d '{"title":"Teste00", "description":"Teste00"}'Listing all products:
curl -X GET localhost:3000/produtoFinding a product:
curl -X GET localhost:3000/produto/idUpdating a product:
curl -X PUT localhost:3000/produto/id -H "Content-Type: application/json" -d '{"title":"...", "description":"..."}'Removing a product:
curl -X DELETE localhost:3000/produto/idIf you encounter any type of Authentication problem with your PostgreSQL: Link of StackoverFlow