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

POST action fails with 404 #647

Open
ghuysmans opened this issue Aug 31, 2020 · 0 comments
Open

POST action fails with 404 #647

ghuysmans opened this issue Aug 31, 2020 · 0 comments

Comments

@ghuysmans
Copy link
Contributor

Hi,
I'm using Eliom 6.12.1 on OCaml 4.08.0 and the action I've defined responds with a 404, even if it actually gets executed. On the client side, I get a strange error but that's no news: that was already reported in #140. Did I do something wrong? Here's a minimal reproducible example, based on the basic.ppx template:

[%%shared
open Eliom_lib
open Eliom_content
open Html.D
]

module Badactions_app =
  Eliom_registration.App (
  struct
    let application_name = "badactions"
    let global_data_path = None
  end)

let ct = ref 0

let set_service =
  Eliom_registration.Action.create
    ~path:(Eliom_service.Path ["set"])
    ~meth:Eliom_parameter.(Eliom_service.Post (
      unit,
      int "value"))
    (fun () value ->
      Format.printf "set %d -> %d@." !ct value;
      ct := value;
      Lwt.return ())

let _ =
  Badactions_app.create
    ~path:(Eliom_service.Path [])
    ~meth:(Eliom_service.Get Eliom_parameter.unit)
    (fun () () ->
       Lwt.return
         (Eliom_tools.F.html
            ~title:"Bad Actions"
            Html.F.(body [
              h1 [txt "Bad Actions"];
              p [
                txt "current value: ";
                txt (string_of_int !ct);
              ];
              Form.post_form ~service:set_service (fun name -> [
                Form.input ~input_type:`Number ~name ~value:42 Form.int;
                button [txt "set"];
              ]) ();
            ])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant