inhabitedtype / ocaml-webmachine

A REST toolkit for OCaml
Other
221 stars 31 forks source link

Question about content_types_accepted #81

Open hadils opened 6 years ago

hadils commented 6 years ago

I have need for the following code:

  method content_types_accepted rd =
    Wm.continue [
      ("application/json;domain-type=Provision", self#provision_facility);
      ("application/json;domain-type=Activate",  self#activate_facility);
      ("application/json;domain-type=Deactivate", self#deactivate_facility);
    ] rd

The purpose is to implement a RESTful interface for CQRS. I need to dispatch on the different domain types independently of the verb used.

Any suggestions? I am new to webmachine, so I am sure I am missing something...

Thanks, Hadil

hadils commented 6 years ago

Additional details. I get a 415 -- Unsupported media type when trying to use PUT with the activate case above. I checked RFC 7231 and it seems that this is legal syntax.

tmcgilchrist commented 6 years ago

The code looks like it should be ok at first glance. I'm hacking up a sample project to see what i can find out, initially I suspect the parsing / matching of those content type strings might be an issue.

Do you have the full http request / response available? e.g. from curl using verbose switch. That should include the web machine trace of which decision nodes it passed through.

On Mon, Jan 8, 2018 at 10:39 AM, Hadil G. Sabbagh, Ph. D. < notifications@github.com> wrote:

Additional details. I get a 415 -- Unsupported media type when trying to use PUT with the activate case above. I checked RFC 7231 and it seems that this is legal syntax.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/inhabitedtype/ocaml-webmachine/issues/81#issuecomment-355862425, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKbuUG2jIUQLr-Y3bscBEkmqx5cICx1ks5tIVWagaJpZM4RV1L- .

hadils commented 6 years ago

I have found a workaround for this, by parsing the content header from Cohttp independently of the webmachine code. It is not parsing the string after the ;.

I will get you a curl output when I have a free moment to test it again.

Thanks, Hadil

On Jan 8, 2018, at 4:08 PM, Tim McGilchrist notifications@github.com wrote:

The code looks like it should be ok at first glance. I'm hacking up a sample project to see what i can find out, initially I suspect the parsing / matching of those content type strings might be an issue.

Do you have the full http request / response available? e.g. from curl using verbose switch. That should include the web machine trace of which decision nodes it passed through.

On Mon, Jan 8, 2018 at 10:39 AM, Hadil G. Sabbagh, Ph. D. < notifications@github.com> wrote:

Additional details. I get a 415 -- Unsupported media type when trying to use PUT with the activate case above. I checked RFC 7231 and it seems that this is legal syntax.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/inhabitedtype/ocaml-webmachine/issues/81#issuecomment-355862425, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKbuUG2jIUQLr-Y3bscBEkmqx5cICx1ks5tIVWagaJpZM4RV1L- .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/inhabitedtype/ocaml-webmachine/issues/81#issuecomment-356125865, or mute the thread https://github.com/notifications/unsubscribe-auth/AEQ-XO5JZBPOnMR-uUUaf4v1GbmApeIZks5tIqAHgaJpZM4RV1L-.

seliopou commented 6 years ago

Webmachine indeed does not take content type parameters into account when performing dispatch. In the short term that's something that should be done manually in the handler for the content type. Not sure if it'd make sense to add that functionality, but I don't see any huge technical hurdle in doing it.

-Spiros E.

i sent this from my Phone.

On Jan 8, 2018, at 6:16 PM, Hadil G. Sabbagh, Ph. D. notifications@github.com wrote:

I have found a workaround for this, by parsing the content header from Cohttp independently of the webmachine code. It is not parsing the string after the ;.

I will get you a curl output when I have a free moment to test it again.

Thanks, Hadil

On Jan 8, 2018, at 4:08 PM, Tim McGilchrist notifications@github.com wrote:

The code looks like it should be ok at first glance. I'm hacking up a sample project to see what i can find out, initially I suspect the parsing / matching of those content type strings might be an issue.

Do you have the full http request / response available? e.g. from curl using verbose switch. That should include the web machine trace of which decision nodes it passed through.

On Mon, Jan 8, 2018 at 10:39 AM, Hadil G. Sabbagh, Ph. D. < notifications@github.com> wrote:

Additional details. I get a 415 -- Unsupported media type when trying to use PUT with the activate case above. I checked RFC 7231 and it seems that this is legal syntax.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/inhabitedtype/ocaml-webmachine/issues/81#issuecomment-355862425, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKbuUG2jIUQLr-Y3bscBEkmqx5cICx1ks5tIVWagaJpZM4RV1L- .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/inhabitedtype/ocaml-webmachine/issues/81#issuecomment-356125865, or mute the thread https://github.com/notifications/unsubscribe-auth/AEQ-XO5JZBPOnMR-uUUaf4v1GbmApeIZks5tIqAHgaJpZM4RV1L-.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.