REST CURL

来源:互联网 发布:java web框架 编辑:程序博客网 时间:2024/05/23 18:23

1 REST  一种软件架构风格

    REST即表述性状态传递(英文:Representational State Transfer,简称REST)是Roy Fielding博士在2000年他的博士论文中提出来的一种软件架构风格。它是一种针对网络应用的设计和开发方式,可以降低开发的复杂性,提高系统的可伸缩性。

      REST中的资源所指的不是数据,而是数据和表现形式的组合,比如"最新访问的10位会员"和"最活跃的10位会员"在数据上可能有重叠或者完全相同,而由于他们的表现形式不同,所以被归为不同的资源,这也就是为什么REST的全名是Representational State Transfer的原因。

2 CURL

     curl是利用URL语法在命令行方式下工作的开源文件传输工具。它被广泛应用在Unix、多种Linux发行版中,并且有DOS和Win32、Win64下的移植版本。

3  Curl example

myemail.json{  "email":"admin@theone.com",  "password":"123456"}.

D:\curl>curl --verbose http://api.dev/platform/auth/web-authenticate -X -POST -d {"email":"admin@theone.com","password":"123456"}*   Trying 192.168.1.101...                                                       //发现是引号的原因   * Connected to api.dev (192.168.1.101) port 80 (#0)> -POST /platform/auth/web-authenticate HTTP/1.1> Host: api.dev> User-Agent: curl/7.49.1> Accept: */*> Content-Length: 40     //*****> Content-Type: application/x-www-form-urlencoded>* upload completely sent off: 40 out of 40 bytes< HTTP/1.1 404 Not Found< Date: Thu, 01 Sep 2016 06:41:38 GMT< Server: Apache/2.4.10 (Debian)< Access-Control-Allow-Credentials: true< Access-Control-Expose-Headers: X-Pagination-Current-Page< Content-Length: 107< Content-Type: application/json; charset=UTF-8<{"state":{"return_code":1004,"return_msg":"(DEBUG) ERR_FORMAT","extra":"","message_uuid":null},"data":null}* Connection #0 to host api.dev left intactD:\curl>curl --verbose http://api.dev/platform/auth/web-authenticate -X -POST -d@myemail.json*   Trying 192.168.1.101...* Connected to api.dev (192.168.1.101) port 80 (#0)> -POST /platform/auth/web-authenticate HTTP/1.1> Host: api.dev> User-Agent: curl/7.49.1> Accept: */*> Content-Length: 48  //*****> Content-Type: application/x-www-form-urlencoded>* upload completely sent off: 48 out of 48 bytes< HTTP/1.1 200 OK< Date: Thu, 01 Sep 2016 06:51:47 GMT< Server: Apache/2.4.10 (Debian)< Access-Control-Allow-Credentials: true< Access-Control-Expose-Headers: X-Pagination-Current-Page< Content-Length: 245< Content-Type: application/json; charset=UTF-8<{"state":{"return_code":0,"return_msg":"OK","extra":"","message_uuid":null},"data":{"id":"57b44a52c3666e03fb12e7a7","email":"admin@theone.com","role":"ADMIN","token":"SYSTOKEN57c7d00366a46","type":"SYS","expire":1472741507,"ip":"192.168.10.14"}}* Connection #0 to host api.dev left intact.


[实践OK]通过命令行能不能打印易读的Json数据怎么办?接合windows使用curl命令输出json并格式化的方法。及升级CentOS下的python到3.3版本的步骤





0 0