metosin / metosin/compojure-api

Mixing compojure.api.sweet/defapi and compojure.core/defroutes

Open
#459 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
1.1k
Forks
146
PR merge metrics
No merged PRs in 30d

Description

## Library Version(s)

[metosin/compojure-api "1.1.13"]
[compojure "1.6.1"]

## Problem

I have two handlers, defined as

(compojure.api.sweet/defapi restful-routes...)
(compojure.core/defroutes public-routes...)

When I combine them with

(compojure.core/routes #'restful-routes #'public-routes)

the POST requests to public routes loose :body parameters. The body comes through as org.eclipse.jetty.server.HttpInputOverHTTP, but it has been read somwhere in the middleware so its content is not available.

I blame compojure.api.sweet for this, because when I reverse the call order to

(compojure.core/routes #'public-routes #'restful-routes)

it works fine, the body streams in POST methods are available in both handlers.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with compojure-api 1.1.13 and compojure 1.6.1 using the two route definitions and both compojure.core/routes orderings. Trace the middleware applied by defapi and defroutes, then verify that POST body parameters remain available regardless of route order.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.