You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting a breakpoint on the parameter line (let deviceID = try req.parameter(String.self)) in the controller's implementation shows that this guard statement fails.
// Core
let coreController = CoreController()
router.get("cores", Core.parameter, use: coreController.getByID)
// Solar
let solarController = SolarController()
router.get("cores", String.parameter, "solar", use: solarController.getSolarForCoreByDeviceID)
The first route uses a Core.parameter whereas the seconds route uses a String.parameter. I would expect the Routing logic to match the requests against all of the configured routes, not the first one it encounters?
I ran into this because I wanted to move from using the Core ID to a property on the Core model (the deviceID) because the integrating party is only aware of coreIDs and I would like to refrain from customizing web hooks on a per-core basis.
Using a
String.parameter
does not work.This seems to be related to this guard statement (also see this discussion with @0xTim):
Steps to reproduce
Create a route that takes a string parameter:
Calling the endpoint (e.g.
{{ url }}/cores/somestring/solar
) will lead to the following error:Setting a breakpoint on the parameter line (
let deviceID = try req.parameter(String.self)
) in the controller's implementation shows that this guard statement fails.Dumping what
slug
anduniqueSlug
are:results in the following output when requesting
{{ url }}/cores/somestring/solar
:Controller:
Expected behavior
I expect a
String.parameter
to not fail when called with a string :)Actual behavior
The request fails with:
Environment
The text was updated successfully, but these errors were encountered: