hapi icon indicating copy to clipboard operation
hapi copied to clipboard

Choose payload.output Based on Content Type

Open pon opened this issue 12 years ago • 4 comments

I have a single endpoint that accepts both multipart/form-data and application/x-www-form-urlencoded.

If I receive multipart I would like to use:

payload: {
  output: 'file',
  parse: true
}

However, if I receive urlencoded I would like to use:

payload: {
  output: 'data',
  parse: true
}

This is not possible currently. Would there be a suggested alternative or is this something that would be desireable to include in the project?

pon avatar Aug 14 '14 19:08 pon

How did you get yourself into this situation? :-) Why aren't these two different endpoints? Or why aren't they always multipart?

hueniverse avatar Aug 15 '14 02:08 hueniverse

We have an API endpoint that accepts either a file upload or a link to a file for a parameter. As a convenience to users we accept both multipart as well as encoded.

pon avatar Aug 15 '14 16:08 pon

How is that a convenience? It would be as easy for them to call two separate endpoints, and would be cleaner for a web form as well. Anyway, there is not current way to do this. I am inclined not to support it because I think the use case is a result of poor API design.

hueniverse avatar Aug 16 '14 00:08 hueniverse

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

lock[bot] avatar Jan 09 '20 04:01 lock[bot]