REST APIs: custom HTTP headers vs URL parameters

后端 未结 8 1241
太阳男子
太阳男子 2020-12-12 11:41

When do you use custom HTTP headers in the request part of a REST API ?

Example:

Would you ever use

GET /orders/view 
(custom HTTP header)          


        
相关标签:
8条回答
  • 2020-12-12 12:25

    I wouldn't use custom headers as you don't know if any proxies will pass those on. URL based is the way to go.

    GET /orders/view/client/23

    0 讨论(0)
  • 2020-12-12 12:26

    I would only use a custom header when there is no other way to pass information by standard or convention. Darren102 is explaining the typical way to pass that value. Your Api will be much more friendly by using typical patterns verse using custom headers.That's not to say you won't have a case to use them, just that they should be the last resort and something not already handled by the HTTP spec.

    0 讨论(0)
提交回复
热议问题