Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How to split routes into multiple paths and subpaths? #7

@tstibbs

Description

@tstibbs

My routes currently look something like this:

{
	'abcLogin': handleAbcLogin,
	'abcLogout': handleAbcVerify,
	'abcDoAction': handleAbcDoAction,
	'xyzLogin': handleXyzLogin,
	'xyzLogout': handleXyzVerify,
	'xyzDoAction': handleXyzDoAction
}

but I'd like the paths to look like this:

{
	'abc/Login': handleAbcLogin,
	'abc/Logout': handleAbcVerify,
	'abc/DoAction': handleAbcDoAction,
	'xyz/Login': handleXyzLogin,
	'xyz/Logout': handleXyzVerify,
	'xyz/DoAction': handleXyzDoAction
}

Adding a slash into the path doesn't appear to work. I also considered trying to created multiple modofun routers so I could have a master router with just routes for abc and xyz and then have 'sub' routers for each of the three routes within abc and xyz. However, afaics that's not going to work because modofun expects the incoming thing to look like a request from AWS etc.

Is there any other way of achieving this?

(this is a really useful library btw, I've used it in loads of serverless projects over the years, thank you!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions