How to register a service that decides itself what to send?

Use Eliom_registration.‚ÄčAny.

In the following example, we send an Html5 page or a redirection:

let send_any =
  Eliom_registration.Any.register_service
    ~path:["any"]
    ~get_params:(string "s")
   (fun s () ->
     if s = "toto"
     then
       Eliom_registration.Html5.send
         (html
            (head (title (pcdata "")) [])
            (body [p [pcdata "Hello."]]))
     else
       Eliom_registration.Redirection.send other_service)