Question

In How to make nicEditor snaplet? (Several questions) I followed the hints and put addRoutes into the snaplet initializer and it worked. After updating snap and heist (0.12) modules to newer, I have some difficulties with addRoutes. If addRoutes is removed from nicsnapInit (in the snaplet example) and put into routes-function in Application.hs, the route is initialized at the same time as other routes in App and route is found.

However, if addRoutes is in nicsnapInit, server just says

no handler accepted "/netext".

This looks like the route is not added.

How to use addRoutes in snaplet initializers at the moment (heist 0.12)?


Learned almost right away that Snap Framework: Custom snaplet handler won't render template has almost similar problem. There addTemplates was used just before addRoutes. After similar changes this seems to work, that is, with line

addTemplates h ""

where h is the parameter at

nicsnapInit :: HasHeist b => Snaplet (Heist b) -> SnapletInit b Nicsnap

and corresponding change to the application initializer.

This changes the url to "niced/netext", i.e. first the snaplet name and then the route that is defined in the snaplet.

Is it possible to add only the "/netext"-part?

Was it helpful?

Solution

Use nestSnaplet "" nicsnap $ nicsnapInit .... The first parameter to nestSnaplet is not the snaplet's name. It is the URL that all the snaplet's routes are relative to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top