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

More transparent middleware setup #7

Open
kkharji opened this issue Jan 9, 2022 · 0 comments
Open

More transparent middleware setup #7

kkharji opened this issue Jan 9, 2022 · 0 comments
Labels
enhancement New feature or request UX

Comments

@kkharji
Copy link
Owner

kkharji commented Jan 9, 2022

Should it be more customizable? I mean I think the ordering matter and simply appending generated middleware might not be viable. My suggestion is, perhaps the user control the list of middleware directly through duct.reitit/middleware:

Right now, here how duct.reitit creates middleware:

(defn- get-router-middleware [{:keys [muuntaja middleware] :as options}]
  (let [format-middleware     (when muuntaja format-middleware)
        exception-middleware  (exception/get-middleware options)
        coercion-middlewares  (coercion/get-middleware options)
        default-middelwares   [custom/initialize-middleware
                               custom/environment-middleware
                               parameters-middleware
                               format-middleware
                               exception-middleware]]
    (compact (vec (concat default-middelwares coercion-middlewares middleware)))))

The ordering of default-middelwares as well as the marge of coercion-middlewares should may be defined by the user like

{:duct.reitit/middleware 
 [:logger-request-middleware
  :environment-middleware 
  :parameter-middleware
  :format-middleware ; should do nothing if muuntaja isn't activated 
  :exception-middleware 
  :coerce-request-middleware ; should do nothing if coercer is nil or coercion isn't activated 
  :coerce-response-middleware ; should do nothing if coercer is nil or coercion isn't activated 
  :user-defined-middleware ;; located in `project-ns/middleware/user-defined-middleware
  user-defined-middleware  ;; symbol located in `project-ns/middleware/user-defined-middleware
]}
@kkharji kkharji added enhancement New feature or request UX labels Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request UX
Projects
None yet
Development

No branches or pull requests

1 participant