質問

This is what I'm currently doing and should return a bus timetable for given bus-routes at given bus stops

/routes/:routeIds/stops/:stopIds

This works for if I want to look up the timetables for multiple routes at a single stop, or multiple stops for a single route, but there's no way for me to specify pairs of specific routes and stops.

e.g.
Multiple stops for a single route: /routes/100/stops/1,2,3
Multiple routes for a single stop: /routes/100,101,103/stops/1

But I can't tell it I want the timetable for 'route 100 at stop 1', 'route 101 at stop 2'

I feel like I'm going about this the wrong way.

役に立ちましたか?

解決

One idea I can think of is just adding several routes and stops pairs to your path, e.g. routes/101,105/stops/4/routes/100/stops/4,9 will give you routes 101 and 105 for stop 4 and route 100 for stops 4 and 9.

Alternatively you could abandon the strict REST concepts and just refactor this into a POST request with JSON something like this: [{routes: [101, 105], stops: [4]}, {routes: [100], stops: [4, 9]}]. This might also be favourable if you plan to add more query parameters in the future, e.g. getting only accessible routes/stops for certain route/stop combinations.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top