From 1b079e856ad9cc8278ee3c11382fd506e1616e8c Mon Sep 17 00:00:00 2001 From: vCaesar Date: Tue, 10 Jan 2017 21:38:47 +0800 Subject: [PATCH] Update introduce --- en/08.3.md | 2 +- zh/08.3.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/en/08.3.md b/en/08.3.md index a2895036..92787090 100644 --- a/en/08.3.md +++ b/en/08.3.md @@ -123,7 +123,7 @@ We can simulate `PUT` and `DELETE` requests by adding a hidden `_method` field i ``` -This sample code shows you how to write a very basic REST application. Our resources are users, and we use different functions for different methods. Here, we imported a third-party package called `github.com/drone/routes`. We've already covered how to implement a custom router in previous chapters -the `drone/routes` package implements some very convenient router mapping rules that make it very convenient for implementing RESTful architecture. As you can see, REST requires you to implement different logic for different HTTP methods of the same resource. +This sample code shows you how to write a very basic REST application. Our resources are users, and we use different functions for different methods. Here, we imported a third-party package called `github.com/julienschmidt/httprouter`. We've already covered how to implement a custom router in previous chapters -the `julienschmidt/httprouter` package implements some very convenient router mapping rules that make it very convenient for implementing RESTful architecture. As you can see, REST requires you to implement different logic for different HTTP methods of the same resource. ## Summary diff --git a/zh/08.3.md b/zh/08.3.md index a77fca44..d08c09a2 100644 --- a/zh/08.3.md +++ b/zh/08.3.md @@ -116,7 +116,7 @@ Go没有为REST提供直接支持,但是因为RESTful是基于HTTP协议实现 } ``` -上面的代码演示了如何编写一个REST的应用,我们访问的资源是用户,我们通过不同的method来访问不同的函数,这里使用了第三方库`github.com/drone/routes`,在前面章节我们介绍过如何实现自定义的路由器,这个库实现了自定义路由和方便的路由规则映射,通过它,我们可以很方便的实现REST的架构。通过上面的代码可知,REST就是根据不同的method访问同一个资源的时候实现不同的逻辑处理。 +上面的代码演示了如何编写一个REST的应用,我们访问的资源是用户,我们通过不同的method来访问不同的函数,这里使用了第三方库`github.com/julienschmidt/httprouter`,在前面章节我们介绍过如何实现自定义的路由器,这个库实现了自定义路由和方便的路由规则映射,通过它,我们可以很方便的实现REST的架构。通过上面的代码可知,REST就是根据不同的method访问同一个资源的时候实现不同的逻辑处理。 ## 总结 REST是一种架构风格,汲取了WWW的成功经验:无状态,以资源为中心,充分利用HTTP协议和URI协议,提供统一的接口定义,使得它作为一种设计Web服务的方法而变得流行。在某种意义上,通过强调URI和HTTP等早期Internet标准,REST是对大型应用程序服务器时代之前的Web方式的回归。目前Go对于REST的支持还是很简单的,通过实现自定义的路由规则,我们就可以为不同的method实现不同的handle,这样就实现了REST的架构。