Questions tagged [compojure-api]

Stuff on top of Compojure for making sweet web apis.

You can read more about it at https://github.com/metosin/compojure-api

51 questions
2
votes
3 answers

How do I bind a dynamic variable?

How do I bind a dynamic variable in compojure? Please see my example below, here the request-id is a unique uuid which is generate for each api request. I would like to be able to access this request-id in subsequent methods for logging etc. I have…
Freid001
  • 2,580
  • 3
  • 29
  • 60
2
votes
1 answer

Carmine connection error during tests

I've a luminus project with some simple compojure-api routes. I've added carmine to communicate with a redis server, using the wcar* macro (defined in services.clj) to make calls to it, and everything works fine. Now I'm trying to add some tests,…
lifeisfoo
  • 15,478
  • 6
  • 74
  • 115
2
votes
1 answer

Compojure-api not respecting body from ring.mock.requests

I'm trying to use the ring.mock.requests library to test an http service. I have this bit of code (auth-routes (-> (mock/request :post "/auth/user") (mock/body {:username "user" :password "pass"}) (mock/content-type…
munk
  • 12,340
  • 8
  • 51
  • 71
1
vote
0 answers

Do Spring Boot applications have a provision of using rest handlers (REST APIs) written in Clojure?

I have a Clojure based web application using Angular JS. All the REST APIs are written in Clojure using Compojure and Ring. Now we want to host our application on a AWS Fargate instance which is a Spring Boot application. I have been looking for a…
Manish
  • 11
  • 3
1
vote
1 answer

How to add default values in request body of swagger docs while using compojure-api

Suppose you have schema like below (s/defschema House {:bedroom s/Int :bathroom s/Int :parking s/Int }) The dynamic generation of swagger docs will assign a default value of 0. How do I assign default value for bedroom, bathroom, and…
Abhishek Jaiswal
  • 628
  • 6
  • 17
1
vote
1 answer

Prismatic/Schema require key dependency?

I am using plumatic/schema with my compojure-api to validate the input for an endpoint. I have two keys in my schema: Field1 & Field2. I want to be able to define a rule for my schema which for example says: WHEN Field1 = "AA" THEN Field2 is…
Freid001
  • 2,580
  • 3
  • 29
  • 60
1
vote
0 answers

How do I obtain all of plain POST form parameters in compojure.api.sweet?

I have a route for which I have to get all of parameters from body. I have no choice because it will be called from a third party system so I have to work with simple tools. I also don't have complete control of the data that is passed and I need…
vvwccgz4lh
  • 86
  • 9
1
vote
1 answer

Query Parameter description in ring-swagger

I'm using ring-swagger via compojure-api. I have a few query parameters and I'm struggling to find a way to add a description to a single query parameter. I can add the summary of the entire endpoint but that's not enough. Is it possible to add a…
siltalau
  • 529
  • 3
  • 17
1
vote
1 answer

How to generate a html page with posted data and create a url for the page to access?

I'm very new to the Clojure-Compojure API development. I have a requirement where I need to create a static html page for every post to my api, fill the content with posted body including styles and a url has to be generated to point to that static…
Shr4N
  • 435
  • 3
  • 18
1
vote
1 answer

Compojure & Ring Middleware Always Returns 404

I'm trying to set up a simple middleware in a luminus project that uses compojure and ring. I'm sure I'm missing something simple, but I've set up a simple middleware to test and I'm not getting the results I expect. (defn wrap-api-auth [handler] …
newBieDev
  • 484
  • 3
  • 11
1
vote
2 answers

Save state on clojure

I'm starting on functional programming now and I'm getting very crazy of working without variables. Every tutorial that I read says that it isn't cool redefine a variable but I don't know how to solve my actual problem without saving the state on a…
Max Forasteiro
  • 382
  • 2
  • 13
1
vote
1 answer

How should I json encode an exception in clojure?

I would like to be able to json encode an exception object. I am pushing my logs to sumologic and would like to be able to push json encoded exception's so that I can parse and filter these logs in sumo too. However, I can't json encode the…
Freid001
  • 2,580
  • 3
  • 29
  • 60
1
vote
1 answer

Get Route record (or :name) for a given request

I'm using compojure-api, and I'm looking for a function that, given my api route structure thingie and a request, returns the Route record (or :name) for that request, without applying its handler. I've been able to find kind of the inverse of what…
Marxama
  • 425
  • 3
  • 13
1
vote
4 answers

Clojure, Compojure: Path Parameter always getting passed as String in Compojure API

I am passing path parameter to fetch data from Database. End Point http://localhost:3000/hello/1000 GET Method Code Code (ns clojure-dauble-business-api.core (:require [compojure.api.sweet :refer :all] [ring.util.http-response :refer…
Srini
  • 823
  • 5
  • 10
  • 29
1
vote
1 answer

Clojure: Difference between defrecord and defschema

I am new to clojure. I want to fetch x records with fields from database and want to insert records into database. Which once should I use between defrecord and defschema in this scenario? Are those the same?
Srini
  • 823
  • 5
  • 10
  • 29