문제

Let's say I have a subdomain that I use for my site's API: http://api.example.com/

All of the API's methods are accessible as URL segments such as http://api.example.com/some_method, so the root itself isn't used for anything.

Should it redirect to http://example.com/, redirect to a 404 page like Twitter, emit a basic response in the format of the API with a short message, or just have it send an empty response?

Are there any resources out there (articles, etc.) with any other possible suggestions?

도움이 되었습니까?

해결책

I think that's up to you. In a RESTful API, the root would be the starting point for visitors to learn how to operate your system (HATEOAS). But since you talk about /some-method, you're probably not using the REST architectural style, so that's not applicable.

I would avoid the empty response. Maybe a short message pointing to documentation for the API? It really depends a lot on how the rest of your system is designed, so it's hard to give "correct" advice.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top