I'm writing HTTP server using HttpListener, that would manage following requests. Each of them should return corresponding JSON object.
GET /command1/command2/command3
GET /command1/<ip-port>/command3
GET /command4/command3
GET /command5/
and so on...
How should I manage this branching of commands?
It seems to me I can easily deal with this using regex. Or maybe I should choose some pattern like State?
You can check out Grapevine , which has this functionality built in. I'm the author of the library, but it's open source , so you can see how I manage routing by reviewing the source code (see src/Grapevine/Server). Or you can just use the library if it to meets your needs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.