I have a simple IHP application which converts farenheit to celsius.
I've stripped out many of the files so that the bulk of the app is in the following file:
After submitting that form, the following page is shown:
Question
As you can see, the two pages are at /Form
and /Result
.
What's a good way to have these show up at:
/Temperature/Form
/Temperature/Result
instead?
Update
Here's a new version of the code based on Marc's answer below:
https://github.com/dharmatech/ConvertTemperatureIhp/blob/002-routing/Web/FrontController.hs
CodePudding user response:
Check out the guide on Custom Routing https://ihp.digitallyinduced.com/Guide/routing.html#custom-routing
Basically you need to remove the instance AutoRoute TemperatureController
and replace it with this:
instance CanRoute TemperatureController where
parseRoute' = do
let form = string "/Temperature/Form" <* endOfInput >> pure FormAction
let result = string "/Temperature/Result" <* endOfInput >> pure ResultAction
form <|> result
instance HasPath TemperatureController where
pathTo FormAction = "/Temperature/Form"
pathTo ResultAction = "/Temperature/Result"