2

I need to write a dispatch routine in java that will take strings as input and output the given method (in string format) they correspond to. The strings would represent endpoints, so something like /guest/leaderboard would direct me to the guestLeaderboards method. It should also handle wildcards, so something like /guests/xxxxx/leaderboard would still take me to the guestLeaderboards (does not need to do anything with the wildcard right now).

I've never done anything like this. I'm looking for examples.

Thanks!

Edit: Been thinking about this a bit more.. could I use a tree where each leaf represents a possible endpoint or method. The algorithm would traverse through the tree based on the tokenized input, where each token is a string between the / but only if it matches my list of keywords (if it doesn't it would be considered a wildcard and thrown out)

zulusam
  • 185
  • 1
  • 8

0 Answers0