Go语言的REST API框架:JAS

jopen 8年前

JAS (JSON API Server) 是一个简单,但强大的Go语言的REST API框架。

主要特性:

  • 不需要手动定义任何URL路由规则,规则按你的资源的结构名和名称定义。 No more inconsistencies between your url path and your method name.

  • Generate all the handled url paths seperated by "\n", so it can be used for reference or detect api changes.

  • Unobtrusive, JAS router is just a http.Handler, you can make it work with other http.Handlers as well as have multiple JAS routers on the same server.

  • Support HTTP Streaming, you can keep an connection open and send real-time data to the client, and get notified when the connection is closed on the client side.

  • Support extract parameters from json request body in any level of depth, so it can be used like JSON RPC.

  • Get and validate request parameter at the same time, support validate a integer, a string's min and max length or rune length, and match a regular expression.

  • Generate default response with the parameter name when validation failed, optionally log the error in Common Log Format.

  • Wrap all unhandled error into InternalError type, write response to the client with default message, and log the stacktraces and request infomation in Common Log Format. and provide a optional function parameter to do the extra error handlling work.

  • Provide an interface to handle errors, so you can define your own error type if the two default implementation can not meet your requirement.

  • 支持gzip压缩

  • 高度可配置

项目主页:http://www.open-open.com/lib/view/home/1368603563078