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¶m2=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¶m2=value2
For example: app --url app://resource?param1=value1¶m2=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
- application schema
References
- restful-api-design
In this page, there are more things like heads, actions, paging, asynchronous are discussed.
请“推荐”本文!