letstring=Tyre.regexRe.(rep1@@compl[char'/'])lethello_name()=Furl.(rel/"hello"/%string/?nil)letgoodbye_name()=Furl.(rel/"goodbye"/%string/?nil)lethandle_hello_name=Printf.sprintf"Hello %s"lethandle_goodbye_name=Printf.sprintf"Goodbye %s"letrouter=Furl.(match_url~default:(fun_->failwith"This is not a valid path.")[hello_name()-->handle_hello_name;goodbye_name()-->handle_goodbye_name])letroute_hello=Oth.test~desc:"Route to the hello path"~name:"Route hello"(fun_->leturi=Uri.of_string"http://test.com/hello/there"inletresp=routeruriinassert(resp="Hello there"))letroute_goodbye=Oth.test~desc:"Route to the goodbye path"~name:"Route goodbye"(fun_->leturi=Uri.of_string"http://test.com/goodbye/you"inletresp=routeruriinassert(resp="Hello you"))lettest=Oth.parallel[route_hello;route_goodbye]let()=Random.self_init();Oth.runtest
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.