#2826 Is there a router library not tied to wisp?

j.longanecker Mon 26 Apr 2021

Hello all, new Fantom developer, I am using it for work with the Fin5 framework, as I am assuming lots of you are.

I am working on a rest API, and am using the Weblet class and overriding onGet. That's not a big deal. I get a request and response object, and that's perfect. However, I am used to working with things like express for JS, which has libraries and tools for routing. If there is a tool that will let me map routes to functions already, that would be amazing.

Otherwise, that's going to be one of my first projects.

Thanks.

andy Mon 26 Apr 2021

Probably more than you need — but take a look at Draft.

Or can just cherry pick this code if its close to what you need:

https://github.com/afrankvt/draft/blob/master/src/fan/Router.fan

Steve might have something too over on EggBox.

Henry Mon 26 Apr 2021

Steve might have something too over on EggBox.

It still technically uses Wisp I believe, but what you're possibly looking for is something like Bedsheet

Steve has also written a couple of guides on bedsheet which can be found here

j.longanecker Mon 26 Apr 2021

@Andy, thank you. Router.fan looks like exactly what I need. Thank you!

go4 Tue 27 Apr 2021

Why we need URL to method mapping? It just call by reflection in slan:

using slanWeb
class Temp : SlanWeblet {
  Void hi() {
    stash("name", "Abc")
    render(`temp.html`)
  }
}

The http://localhost:8080/Temp/hi will route to Temp.hi method.

Login or Signup to reply.