开发者

How are URI's handled in a REST api?

开发者 https://www.devze.com 2023-04-07 08:57 出处:网络
I\'m creating a hobby iOS app, and I\'m a bit confused about how to create a REST backend for it.I\'ve read the resources available on the internet and I understand the theories behind REST.However, I

I'm creating a hobby iOS app, and I'm a bit confused about how to create a REST backend for it. I've read the resources available on the internet and I understand the theories behind REST. However, I'm confused about how the URI's get handled. For instance, is there a file handling rest functions at /resource/ or /resource/{id} or are these files sitting at 开发者_StackOverflowroot, and somehow the URI calls are getting routed to them? Excuse my ignorance at web design.


That depends on the server architecture. It’s perfectly legal to have only separate CGI files sitting in appropriate folders and handling the requests, maybe in conjuction with some URL rewriting to have nice URLs.

On the other hand most modern web frameworks have some kind of URL dispatcher. That’s a core component of the framework, and it takes care of dispatching (= mapping) requests to various pieces of code (usually classes and methods).

There’s for example a modern Perl framework called Mojolicious. Even without knowing any Perl you might find its documentation about routing interesting, for it answers your question quite well.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号