前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >RESTful Console Application

RESTful Console Application

作者头像
绿巨人
发布2018-07-04 15:30:52
7970
发布2018-07-04 15:30:52
举报
文章被收录于专栏:绿巨人专栏

RESTful Console Application

Introduction

Inspirited by RESTFul architecture, A console application targeted to same goals would use a match of RESTful definitions.

Design

For convenience, we name the imaginary console application as 'app'.

RESTful WebService objects

  • Authentication Request header: Authentication Value: "Basic " or ":"

Property

Description

username

The user name in the Basic Authentication

password

The user name in the Basic Authentication

For authentication methods OAuth and OAuth, we will consider then later.

  • Headers Headers are a list of header in key-value form. See.
  • Method

Using HTTP Methods for RESTful Services

Method

Meaning

POST

Create

GET

Read

PUT

Update/Replace

DELETE

Delete

PATCH

Update/Modify

  • Error Code

Code

Meaning

200

OK

401

Unauthorized

404

Not Found

409

Conflict if the resource already exists

500

Internal Exception

  • URL http(s)://website/resource?param1=value1&param2=value2
  • Request
  • Response A content in json format.

RESTful Console application

  • Authentication

Arguments:

Argument

Description

username

The user name in the Basic Authentication

password

The user name in the Basic Authentication

For example: app --username username --password pwd We will implement authentication methods OAuth and OAuth later.

  • Headers Reserved.
  • Method

Method

Meaning

HEAD

Return an empty json file for creating/updating

POST

Create

GET

Read

PUT

Update/Replace

DELETE

Delete

For example: app --method get

  • Error Code

Code

Meaning

0

OK

401

Unauthorized

404

Not Found

409

Conflict if the resource already exists

500

Internal Exception

  • URL app://resource?param1=value1&param2=value2 For example: app --url app://resource?param1=value1&param2=value2
  • Request A content in json format. For example: app --request path/to/request.body
  • Response The console application output in json format.
代码语言:javascript
复制
{
    "status": 200,
    "response" : {}
}

More considerations

  • asynchronous
  • paging
  • export/print Export data into a csv/html(or other format) file.
  • imports
  • get urls definitions of all resources
  • meaningful URL
    • application schema app://schema/entities/entity points to a metadata resource of an entity. app://schema/application points to the resource of the application.
    • application resource(data) app://application/entities/entity points to data resource of an entity.
    • user for the current user information

References

  • restful-api-design In this page, there are more things like heads, actions, paging, asynchronous are discussed.
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-10-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • RESTful Console Application
    • Introduction
      • Design
        • RESTful WebService objects
        • RESTful Console application
      • More considerations
        • References
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档