B4J Question B4J web server routes grouping

mmanso

Active Member
Licensed User
Longtime User
Hi there,

With a B4J webserver (jetty) is possible to group a list of routes in a single class to avoid having a lot of classes?

I mean, something like:

/products/list
/products/add
/products/delete
(Etc)

I would like to have those on a single Products class and not a class for each one.

Is this possible?

Thanks.
 

tchart

Well-Known Member
Licensed User
Longtime User
Yes you can wildcard the routes and point to a single class. The class would need to check the incoming URL and change behaviour. Pretty sure I've done this in the past.

Alternatively define each route and point them to the same class. I do this for a CRUD system for a SQL database .
 
Upvote 0

FrostCodes

Active Member
Licensed User
Longtime User
Hi there,

With a B4J webserver (jetty) is possible to group a list of routes in a single class to avoid having a lot of classes?

I mean, something like:

/products/list
/products/add
/products/delete
(Etc)

I would like to have those on a single Products class and not a class for each one.

Is this possible?

Thanks.

Hi , check out this: https://www.b4x.com/android/forum/threads/cuppify-build-modern-rest-apis-with-ease.100923/

it has something similar and a cleaner solution
 
Upvote 0
Top