A question about restful design

Source: Internet
Author: User
Recently, when writing about AWS-related development, there is a problem: for example, how do you create, restart, stop, delete, and so on for instance, if you want to implement it in a restful design style?

GET     /etc/instance/    获取instancePOST    /ec2/instance/    创建instanceDELETE  /etc/instance/    删除instance

How about restarting, stopping, etc.? With put?

Reply content:

Recently, when writing about AWS-related development, there is a problem: for example, how do you create, restart, stop, delete, and so on for instance, if you want to implement it in a restful design style?

GET     /etc/instance/    获取instancePOST    /ec2/instance/    创建instanceDELETE  /etc/instance/    删除instance

How about restarting, stopping, etc.? With put?

Just do a management service Restsful API design, say my design ideas for reference.

# 创建POST /ec2/instance# 查询状态GET /ec2/instance/:id# 删除(terminate)DELETE /ec2/instance/:id# 启动、重启等都算作修改状态,假定是在修改 instance 的 status 属性# 启动PUT /ec2/instance/:idForm data: status=start# 停止PUT /ec2/instance/:idForm data: status=stop# 启动,如果已启动就重启PUT /ec2/instance/:id?force=1Form data: status=start

Answer with a rails URL design, lazy hands.

What is restful?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.