Fork me on GitHub
#reitit
<
2023-11-09
>
neilprosser22:11:07

This is a similar sort of question to https://clojurians.slack.com/archives/C7YF1SBT3/p1698852178160519 and I thought I'd start off in here rather than launching straight into an issue on GitHub. I'm aiming for a GCP-style API POST where the API can specify 'commands' against a resource with a colon prefix. I've switched the router :syntax to :bracket and it's working for some parts of my API. However, I've hit one particular combination of routes which doesn't seem to work. I think I've distilled the issue I'm seeing into the following example in the thread and I'd really appreciate some advice.

neilprosser22:11:25

(ns my-namespace
  (:require [reitit.core :as r]))

(def routes
  ["/a/{b}"
   ["/c"]
   [":d"]])

(r/router
 routes
 {:conflicts (constantly nil) ;; doesn't suppress conflict error
  :syntax :bracket})

; Execution error (ExceptionInfo) at reitit.exception/exception (exception.cljc:19).
; :reitit.trie/multiple-terminators
;
; {:terminators ("/c" ":d"), :path "/a/{b}"}

(r/router
 routes
 {:conflicts (constantly nil) ;; suppresses conflict error
  :syntax :colon})

(r/router
 routes
 {:conflicts (constantly nil)}) ;; doesn't suppress conflict error

; Execution error (ExceptionInfo) at reitit.exception/exception (exception.cljc:19) .
; :reitit.trie/following-parameters
;
; {:path "/a/{b}:d", :parameters (:b :d)}
I think there are a couple of problems here. The first is that I'm getting a conflict error. I feel like if I've switched to :bracket syntax the :d should be recognised as a literal rather than a parameter (if that's what's even happening here) so it should be valid. The second is that I don't seem to be able to suppress the conflict error using the conflicts option. It doesn't seem to work when I'm using :colon syntax but not if :bracket is used. If anyone is able to shed some light on whether I've misunderstood something I'd be very grateful!