Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Okay this is ridiculous: (or probably my design is :)

Here are the URLs that we are using:


/{projectName}/{wallName}        - GET only: fetch all win conditions posted to the all
/{projectName}/WinCondition      - POST a new Win Condition
/{projectName}/WinCondition/{id} - GET, PUT & DELETE

Now the funny part:

If the code is ordered as above the call POST: /myProject/WinCondition gets routed to the first route with wallName! And thus get a 405.

If I shift the /{projectName}/{wallName} to the bottom then it gets routed correctly!

Now here's what I know:

  • The default routing mode in Restlet is MODE_FIRST_MATCH. I set that to MODE_BEST_MATCH and the order of URLs still matters! I am unable to access the 'affinity' score to check what's the problem/score. Matching mode is Template.MODE_EQUALS.

The question is then this: Do I have to be concerned with how I order the URLs in my java file???? That'll be scary, even from a maintenance point of view.

Any suggestions? Should I redesign my URLs?? But the 'structure' still tends to be the same leading to the same problem

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
194 views
Welcome To Ask or Share your Answers For Others

1 Answer

"/{projectName}/{wallName}" and "/{projectName}/WinCondition" will obtain the same score for both FIRST_MATCH and BEST_MATCH so it is still the first in the route list that wins.

But this is really a side effect that you shouldn't get yourself into generally speaking. The problem is that it looks like you propose two routes to two different resource classes for the same URIs (such as "/myProject/WindCondition").

You should really consider redesigning your URIs to prevent such conflict. Here is a suggestion:

  • /{projectName}/walls/{wallName}
  • /{projectName}/winCondition
  • /{projectName}/winCondition/{id]

Otherwise, if relying on routes order scares you, it is possible to customize the default routing logic to take into account the target method for the scoring.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...