专栏首页绿巨人专栏RESTful Console Application

RESTful Console Application

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.
{
    "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.

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • RESTful Console Application

    绿巨人
  • Architecture : Describable Command and Identifiable Data

    绿巨人
  • Database Design Guidelines

    绿巨人
  • RESTful Console Application

    绿巨人
  • python列表中的赋值与深浅拷贝

    [[1, 'tom', 3], 4, 5, 6] [[1, 'tom', 3], 4, 5, 6]

    用户2398817
  • iOS define 和 const常量区别?

    ●define是宏定义,程序在预处理阶段将用define定义的内容进行了替换。因此程序运行时,常量表中并没有用define定义的常量,系统不为它分配内存。con...

    赵哥窟
  • Angular2入门体验

    好的工具往往使得开发应用更快更简单,而不是任何模块都手动开发。angualr cli就是一个支持 创建工程,添加文件,对各种任务如测试、打包、部署等迭代。 本文...

    用户1154259
  • 解决Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named

    LinXunFeng
  • python常见模块之collections模块

    一、模块简介 在内置数据类型(dict、list、set、tuple)的基础上,collections模块还提供了几个额外的数据类型:Counter、deque...

    人生不如戏
  • 一篇文章精通PowerShell Empire 2.3(下)

    Empire主要用于后渗透。所以信息收集是比较常用的一个模块,我们可以使用searchmodule命令搜索需要使用的模块,这里通过键入“usemodule co...

    HACK学习

扫码关注云+社区

领取腾讯云代金券