Fork me on GitHub
#reitit
<
2019-12-12
>
marcio01:12:57

I'm trying to using spec coercion with pedestal, but it seems that the exception-interceptor doesn't work properly.

marcio01:12:05

clojure.lang.ExceptionInfo: clojure.lang.ExceptionInfo in Interceptor :reitit.http.interceptors.muuntaja/format-response - Malformed application/json in :muuntaja/encode

marcio01:12:21

The interceptor chain that throws a :error

marcio01:12:49

{:enter nil,
 :error #<[email protected]>,
 :leave nil,
 :name :reitit.http.interceptors.exception/exception,
 :spec :reitit.http.interceptors.exception/spec}

marcio01:12:13

I tried with the examples on http-swagger and the response contains the spec errors

marcio01:12:48

but with the pedestal-swagger I get just an Exception Info

marcio01:12:22

I'm forgetting to do something?

joshkh18:12:15

i'm sure this has been answered many times but i can't seem to find it in the docs/issues. can i serve a static resource in such a way that requests to /* provide my index.html without appending index.html to the url?

ikitommi19:12:38

@joshkh it should work oob if the index-file exists, but it's usually good idea to add a trailing space handler to auto-fill urls like /docs -> /docs/ -> /docs/index.html. see https://cljdoc.org/d/metosin/reitit/0.3.10/doc/ring/slash-handler

ikitommi19:12:26

@marciogiaxa so the pedestal swagger example fails?

joshkh20:12:50

thanks @ikitommi. so assuming that /resources/public/index.html exists and i visit , i shouldn't be "redirected" to ?

(def app
  (ring/ring-handler
    (ring/router
      [api-routes/routes]
      {
       :conflicts (constantly nil)
       :data      {:muuntaja   m/instance
                   :coercion   reitit.coercion.spec/coercion
                   :middleware [params/wrap-params
                                muuntaja/format-middleware
                                coercion/coerce-exceptions-middleware
                                coercion/coerce-request-middleware
                                coercion/coerce-response-middleware
                                [wrap-cors identity]]}})
    (ring/routes
      (ring/create-resource-handler {:path "/"})
      (ring/create-default-handler))))

joshkh20:12:48

(and thanks for the slash handler tip - that's been on my mind as well 🙂)

joshkh20:12:38

it seems that even with the example in the docs verbatim, i end up with index.html in the url (using reitit v3.10.0)

(ring/ring-handler
  (ring/router
    ["/ping" (constantly {:status 200, :body "pong"})])
  (ring/routes
    (ring/create-resource-handler {:path "/"})
    (ring/create-default-handler)))

marcio21:12:11

@ikitommi yes, but is was debugging here and I think that is a dependency conflict.

marcio22:12:44

thanks.. I'll check it

marcio21:12:41

more exactly with the jackson-databind.

marcio21:12:24

this is the error that I got

marcio21:12:28

com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)