Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reitit.pedestal/replace-last-interceptor does not replace pedestal router #680

Open
timgilbert opened this issue May 1, 2024 · 0 comments

Comments

@timgilbert
Copy link

I'm not sure what the intent is for (replace-last-interceptor) but it seems to aim to replace the built-in pedestal router with the reitit one instead.

However, it doesn't actually do that in the latest two versions of pedestal, because pedestal's routing interceptor is not at the end of the list:

(require '[io.pedestal.http :as http])
; => nil
(-> {:env :dev ::http/type :jetty ::http/port 8080 ::http/routes []}
    (http/default-interceptors))
; =>
{:env :dev,
 :io.pedestal.http/type :jetty,
 :io.pedestal.http/port 8080,
 :io.pedestal.http/routes [],
 :io.pedestal.http/interceptors [#Interceptor{:name :io.pedestal.http/log-request}
                                 #Interceptor{:name :io.pedestal.http/not-found}
                                 #Interceptor{:name :io.pedestal.http.ring-middlewares/content-type-interceptor}
                                 #Interceptor{:name :io.pedestal.http.route/query-params}
                                 #Interceptor{:name :io.pedestal.http.route/method-param}
                                 #Interceptor{:name :io.pedestal.http.secure-headers/secure-headers}
                                 #Interceptor{:name :io.pedestal.http.route/router}
                                 #Interceptor{:name :io.pedestal.http.route/path-params-decoder}]}

;;;;

(-> {:env :dev ::http/type :jetty ::http/port 8080 ::http/routes []}
    (http/default-interceptors)
    (pedestal/replace-last-interceptor (pedestal/routing-interceptor [])))

{:env :dev,
 :io.pedestal.http/type :jetty,
 :io.pedestal.http/port 8080,
 :io.pedestal.http/routes [],
 :io.pedestal.http/interceptors [#Interceptor{:name :io.pedestal.http/log-request}
                                 #Interceptor{:name :io.pedestal.http/not-found}
                                 #Interceptor{:name :io.pedestal.http.ring-middlewares/content-type-interceptor}
                                 #Interceptor{:name :io.pedestal.http.route/query-params}
                                 #Interceptor{:name :io.pedestal.http.route/method-param}
                                 #Interceptor{:name :io.pedestal.http.secure-headers/secure-headers}
                                 #Interceptor{:name :io.pedestal.http.route/router}
                                 #Interceptor{:name :reitit.http/router}]}

The (replace-last-interceptor) call replaces the ::http/path-params-decoder interceptor instead.

(You can see the code which generates these here.)

Is there a better way to replace the pedestal router? Should I instead just leave the interceptor alone, add the reitit.pedestal/routing-interceptor to the end of my list of interceptors, and set the pedestal ::http/routes to []?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant