From 78fc6dd36ec2244cb42ebca87729183a62a4e39c Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Wed, 26 Feb 2014 17:15:02 +0000 Subject: New port: devel/go-rest-json: Go-Json-Rest is a thin layer on top of net/http that helps building RESTful JSON APIs easily. It provides fast URL routing using a Trie based implementation, and helpers to deal with JSON requests and responses. It is not a high-level REST framework that transparently maps HTTP requests to procedure calls, on the opposite, you constantly have access to the underlying net/http objects. WWW: https://github.com/ant0ine/go-json-rest/ --- devel/go-json-rest/Makefile | 18 ++++++++++++++ devel/go-json-rest/distinfo | 2 ++ devel/go-json-rest/files/patch-request.go | 39 +++++++++++++++++++++++++++++++ devel/go-json-rest/pkg-descr | 8 +++++++ devel/go-json-rest/pkg-plist | 35 +++++++++++++++++++++++++++ 5 files changed, 102 insertions(+) create mode 100644 devel/go-json-rest/Makefile create mode 100644 devel/go-json-rest/distinfo create mode 100644 devel/go-json-rest/files/patch-request.go create mode 100644 devel/go-json-rest/pkg-descr create mode 100644 devel/go-json-rest/pkg-plist (limited to 'devel/go-json-rest') diff --git a/devel/go-json-rest/Makefile b/devel/go-json-rest/Makefile new file mode 100644 index 000000000000..000303fa95a4 --- /dev/null +++ b/devel/go-json-rest/Makefile @@ -0,0 +1,18 @@ +# Created by: Ryan Steinmetz +# $FreeBSD$ + +PORTNAME= go-json-rest +PORTVERSION= 20140226 +CATEGORIES= devel +MASTER_SITES= LOCAL/zi/ \ + http://mirrors.rit.edu/zi/ + +MAINTAINER= lattera@gmail.com +COMMENT= Quick and easy way to setup a RESTful JSON API + +GO_PKGNAME= github.com/ant0ine/go-json-rest +WRKSRC= ${WRKDIR}/${PORTNAME}-master + +.include +.include "${PORTSDIR}/lang/go/files/bsd.go.mk" +.include diff --git a/devel/go-json-rest/distinfo b/devel/go-json-rest/distinfo new file mode 100644 index 000000000000..d0f2297f15fc --- /dev/null +++ b/devel/go-json-rest/distinfo @@ -0,0 +1,2 @@ +SHA256 (go-json-rest-20140226.tar.gz) = b2d04af83c7c6c6819e5d6518b1a8c4b3a25c744ee917194ba4e7255f424e5f0 +SIZE (go-json-rest-20140226.tar.gz) = 16373 diff --git a/devel/go-json-rest/files/patch-request.go b/devel/go-json-rest/files/patch-request.go new file mode 100644 index 000000000000..a2ae86de6032 --- /dev/null +++ b/devel/go-json-rest/files/patch-request.go @@ -0,0 +1,39 @@ +--- ./request.go.orig 2014-02-25 00:55:56.000000000 -0500 ++++ ./request.go 2014-02-26 11:51:45.000000000 -0500 +@@ -15,19 +15,34 @@ + PathParams map[string]string + } + ++func CToGoString(c []byte) string { ++ n := -1 ++ for i, b := range c { ++ if b == 0 { ++ break ++ } ++ n = i ++ } ++ return string(c[:n+1]) ++} ++ + // Provide a convenient access to the PathParams map + func (self *Request) PathParam(name string) string { + return self.PathParams[name] + } + + // Read the request body and decode the JSON using json.Unmarshal +-func (self *Request) DecodeJsonPayload(v interface{}) error { ++func (self *Request) DecodeJsonPayload(v interface{}, decodeBody bool) error { + content, err := ioutil.ReadAll(self.Body) + self.Body.Close() + if err != nil { + return err + } +- err = json.Unmarshal(content, v) ++ contentstr := "" ++ if decodeBody == true { ++ contentstr, _ = url.QueryUnescape(CToGoString(content)) ++ } ++ err = json.Unmarshal([]byte(contentstr), v) + if err != nil { + return err + } diff --git a/devel/go-json-rest/pkg-descr b/devel/go-json-rest/pkg-descr new file mode 100644 index 000000000000..3f4d120a9d1f --- /dev/null +++ b/devel/go-json-rest/pkg-descr @@ -0,0 +1,8 @@ +Go-Json-Rest is a thin layer on top of net/http that helps building RESTful +JSON APIs easily. It provides fast URL routing using a Trie based +implementation, and helpers to deal with JSON requests and responses. It is +not a high-level REST framework that transparently maps HTTP requests +to procedure calls, on the opposite, you constantly have access to the +underlying net/http objects. + +WWW: https://github.com/ant0ine/go-json-rest/ diff --git a/devel/go-json-rest/pkg-plist b/devel/go-json-rest/pkg-plist new file mode 100644 index 000000000000..447eb9926779 --- /dev/null +++ b/devel/go-json-rest/pkg-plist @@ -0,0 +1,35 @@ +@comment $FreeBSD$ +%%GO_LIBDIR%%/github.com/ant0ine/go-json-rest.a +%%GO_SRCDIR%%/%%GO_PKGNAME%%/LICENSE +%%GO_SRCDIR%%/%%GO_PKGNAME%%/README.md +%%GO_SRCDIR%%/%%GO_PKGNAME%%/env.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/gzip.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/gzip_test.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/handler.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/handler_test.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/log.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/recorder.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/request.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/request.go.orig +%%GO_SRCDIR%%/%%GO_PKGNAME%%/request_test.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/response.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/router.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/router_benchmark_test.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/router_test.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/status.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/status_test.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/test/util.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/timer.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/trie/impl.go +%%GO_SRCDIR%%/%%GO_PKGNAME%%/trie/impl_test.go +@dirrm %%GO_SRCDIR%%/%%GO_PKGNAME%%/test +@dirrm %%GO_SRCDIR%%/%%GO_PKGNAME%%/trie +@dirrmtry %%GO_SRCDIR%%/%%GO_PKGNAME%% +@dirrmtry %%GO_SRCDIR%%/github.com/ant0ine +@dirrmtry %%GO_SRCDIR%%/github.com +@dirrmtry %%GO_LIBDIR%%/github.com/ant0ine +@dirrmtry %%GO_LIBDIR%%/github.com +@dirrmtry %%GO_LIBDIR%% +@dirrmtry %%GO_SRCDIR%% +@dirrmtry share/go/pkg +@dirrmtry share/go -- cgit v1.2.3