donglue1886 2016-01-25 16:43
浏览 134

创建Restful API在响应之前应该放置哪种标头?

I am not finding a whole lot of information on this, maybe I am just searching wrong, who knows.. What I want to know or try to figure out is what kind of headers should I output for API responses example

header('Content-Type: application/json');

Is something I would put out for the type of data, but are there others for time, expiration, or anything else for that matter that I should concern myself with?

Ultimately I am attempting to make an API for an app I want to develope so I am trying to figure out early what will be cross platform compliant and what needs are so I can try to build them into my idea of what would be part of standard dev

  • 写回答

2条回答 默认 最新

  • dongzong2017 2016-01-25 18:40
    关注

    One good thing that I include in my response headers is a correlation id for the request that was sent. This allows consumers of your API to correlate a question or a potential bug with a request and allow you to look up information pertaining to that request.

    This, of course, requires you to log information associated to the correlation id but it has proven to be very useful for me.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题