Fork me on GitHub
#pedestal
<
2016-10-18
>
scott.haleen19:10:53

Is there a sample of how to handle fileupload or just multipart/form-data with pedestal?

mtnygard19:10:52

(At my fingertips because I'm working on a doc that should incorporate that info. Like right now.)

souenzzo19:10:10

Hello! How do I handle internal erros(exceptions)? curl '' returns text/plain 500 Internal server error Internally: clojure.lang.ExceptionInfo: Interceptor Exception: URLDecoder: Incomplete trailing escape (%) pattern Can I intercept/handle this to make a custon response?

scott.haleen19:10:17

awesome thanks, I will check that out

mtnygard19:10:47

Hi @souenzzo. You sure can. Take a look at http://pedestal.io/reference/error-handling and let me know if it tells you what you need to know.

souenzzo19:10:37

It seems that this happens before this interceptor

souenzzo19:10:19

My :else dosen't get this except....

mtnygard19:10:46

Which :else would that be?

souenzzo19:10:39

My :else on io.pedestal.interceptor.error/error-dispatch macro. I'ts my first interceptor on (def r table-routes [["/query" :get [err-interceptor query] :route-name :query])

mtnygard19:10:05

Interesting! Give me a minute to try to replicate that.

mtnygard19:10:14

I can definitely reproduce the problem. Looking into a solution now.

souenzzo19:10:14

On my example is missing the ?. minimal example shoud be localhost/?%

mtnygard19:10:28

OK, I've got an explanation and a solution for you. Which would you like to have first? 🙂

mtnygard19:10:03

In the interest of time, I'll start with the solution.

mtnygard19:10:34

1. Instead of putting the error handling in your routes, you will need to have it come early in the chain of interceptors. Before the router, in fact. The way to do this is as follows:

mtnygard19:10:01

- Call io.pedestal.http/default-interceptors with your service map. The result will be a service map with the default interceptors attached.

mtnygard19:10:24

- Prepend your error handler to the :io.pedestal.http/interceptors key in the service map.

mtnygard19:10:40

- Call create-servlet or create-server as normal. The default interceptors will not be appended a second time.

mtnygard19:10:20

2. Explanation: the exception is happening before a route is selected by the router. Thus, your error handling interceptor never gets pushed onto the stack.

mtnygard19:10:50

As an aside: I'll be updating the error handling reference to cover this case.

mtnygard21:10:06

New reference document drafted: parameters (query params, body params, and path params)

mtnygard21:10:38

There's a heading that says "placeholder" in there... a commit that removes it is working its way through Travis right now.