【问题标题】:Api Blueprint and long running jobsApi 蓝图和长时间运行的作业
【发布时间】:2015-06-19 08:58:55
【问题描述】:

我想用long running jobsBlueprint 正确设计我的json API。 我需要处理文件,返回带有位置标头的202 Accepted,然后设计将接收303 See Other 的临时位置,然后设计最终对象201 Created

有没有办法正确设计这个序列?

【问题讨论】:

    标签: json api rest apiblueprint


    【解决方案1】:

    蓝图可能如下所示:

    # Stars [/stars]
    
    Collection of stars.
    
    ## Create [POST]
    + Request (application/json)
    
        Create a star
    
        + Body
    
                {"name": "Death Star"}
    
    + Response 202
    
        Request has been accepted into the queue. Poll the queue item to check the result. 
    
        + Headers
    
                Location: /queue/12345
    
    
    # Queue Item [/queue/{id}]
    
    One item in a job queue.
    
    + Parameters
        + id: 12345 (number) - Id of the queue
    
    ## Query Status [GET]
    + Response 200 (aplication/xml)
    
        The job is still in progress.
    
        + Body
    
                <response>
                    <status>PENDING</status>
                    <eta>2 mins.</eta>
                    <link rel="cancel" method="delete" href="/queue/12345" />
                </response>
    
    + Response 303
    
        The job has finished. See the created resource.
    
        + Headers
    
                Location: /stars/97865
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-12
      • 1970-01-01
      • 2020-04-26
      • 1970-01-01
      • 2017-06-18
      • 2022-09-28
      • 1970-01-01
      相关资源
      最近更新 更多