bryanxu / gorest Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/gorest
Automatically exported from code.google.com/p/gorest
Since the use of back-quotes allows for a multi-line string, could we have this
more readable version:
...
listApplications gorest.EndPoint `
method:"GET"
path:"/applications"
output:"string"`
...
Current version (2012/11/07) does not parse this correctly.
Original issue reported on code.google.com by [email protected]
on 7 Nov 2012 at 12:15
What steps will reproduce the problem?
1. Register the "hello" service with http.Handle("/api", gorest.Handle()) where
the entrypoint is not "/"
2. Try to access the webservice under "/api/hello/name"
What is the expected output? What do you see instead?
I expect the API to just work under a different entrypoint, but it always
fails. This prevents me from using the same port for the website and the API
serving.
Original issue reported on code.google.com by [email protected]
on 24 Apr 2014 at 12:42
What steps will reproduce the problem?
1. Install Go weekly (last one)
2. After that, try to install gorest through 'goinstall
gorest.googlecode.com/hg/gorest'
3. Error: goinstall: gorest.googlecode.com/hg/gorest: install: running bash:
exit status 2
What is the expected output? What do you see instead?
I expected the correct installation of gorest framework. Instead, I've got an
error.
What version of the product are you using? On what operating system?
Go, last weekly revision, on a Mac OS X Lion enviroment.
Please provide any additional information below.
Full error:
goinstall gorest.googlecode.com/hg/gorest
/bin/bash: === cd
/Users/ricky/Desenvolvimento/go/src/pkg/gorest.googlecode.com/hg/gorest; bash
gomake -f- install
6g -I "/Users/ricky/Desenvolvimento/go/pkg/darwin_amd64" -I
"/Users/ricky/Desenvolvimento/go/pkg/darwin_amd64" -p
gorest.googlecode.com/hg/gorest -o _go_.6 api.go client.go doc.go gorest.go
marshaller.go mime.go parse.go reflect.go sec.go util.go
client.go:161: undefined: http.ParseURL
client.go:173: undefined: http.ParseURL
client.go:185: undefined: http.ParseURL
client.go:205: undefined: http.ParseURL
client.go:227: undefined: http.ParseURL
gorest.go:136: undefined: http.URLUnescape
make: *** [_go_.6] Error 1
--- exit status 2
goinstall: gorest.googlecode.com/hg/gorest: install: running bash: exit status 2
Regards.
Original issue reported on code.google.com by [email protected]
on 11 Oct 2011 at 7:02
What steps will reproduce the problem?
- always.
Minor:
Change code snippets import rules; they moved "http" to "net/http"; could
confuse go newcomer.
Original issue reported on code.google.com by [email protected]
on 31 Oct 2012 at 4:47
1 Why need to specify the post data, params argument and output type?
All of post data, params argument and output type can be found from function signature, using order in signature. That will allow to use type defined in other package more easily, like: http://play.golang.org/p/FUj-FXKr71
2 Why Marshaller takes []byte instead of io.Reader/io.Writer?
I think use io.Reader/io.Writer will much convenience for streaming io. Direct reading from request.Body or writing to responseWriter will also save a lot of memory if post or response is very large.
Original issue reported on code.google.com by [email protected]
on 7 Mar 2013 at 9:24
What steps will reproduce the problem?
package main
import (
"fmt"
"net/http"
goRest "code.google.com/p/gorest"
rethinkDb "github.com/christopherhesse/rethinkgo"
)
func main() {
goRest.RegisterService(new(Console)) //Register our service
http.Handle("/", goRest.Handle())
fmt.Printf("Web Application Listening...\n")
http.ListenAndServe(":3000", nil)
}
//Service Definition
type Console struct {
goRest.RestService `root:"/" consumes:"application/json" produces: "application/json"`
getReadings goRest.EndPoint `method:"GET" path:"/readings/" output:"[]interface{}"`
}
func (serv Console) GetReadings()([]interface{}) {
databaseName := "test"
tableName := "readings"
session, _ := rethinkDb.Connect("localhost:28015", databaseName)
var response []interface{}
_ = rethinkDb.Table(tableName).Run(session).All(&response)
fmt.Printf("response:", response)
return response
}
What is the expected output? What do you see instead?
I expect to have the application startup without issue...
Instead I get this error...
$ go run console.go
2013/04/22 22:38:29 All EndPoints for service [ Console ] , registered under
root path: /
2013/04/22 22:38:29 Parameter list not matching. No matching Method found for
EndPoint:[getReadings],type:[GET] . Expecting: #func(serv Console)
GetReadings()([]interface{})# with one([]interface{}) return parameter.
panic: Parameter list not matching. No matching Method found for
EndPoint:[getReadings],type:[GET] . Expecting: #func(serv Console)
GetReadings()([]interface{})# with one([]interface{}) return parameter.
goroutine 1 [running]:
log.Panic(0x2500bd8, 0x100000001)
/usr/local/go/src/pkg/log/log.go:307 +0x9f
code.google.com/p/gorest.mapFieldsToMethods(0xf84008b000, 0x1f7f18, 0x2233cc,
0x527465670000000b, 0x22426c, ...)
/Users/nunya/.mygo/src/code.google.com/p/gorest/reflect.go:103 +0x684
code.google.com/p/gorest.registerService(0x217c1c, 0xf800000000, 0x1f1fa8,
0xf84006bb00, 0x1f1fa8, ...)
/Users/nunya/.mygo/src/code.google.com/p/gorest/reflect.go:66 +0x4ad
code.google.com/p/gorest.RegisterServiceOnPath(0x217c1c, 0x0, 0x1f1fa8,
0xf84006bb00, 0x204d, ...)
/Users/nunya/.mygo/src/code.google.com/p/gorest/gorest.go:182 +0x116
code.google.com/p/gorest.RegisterService(0x1f1fa8, 0xf84006bb00)
/Users/nunya/.mygo/src/code.google.com/p/gorest/gorest.go:137 +0x42
main.main()
/Users/nunya/Projects/golang/console/console.go:15 +0x4d
goroutine 2 [syscall]:
created by runtime.main
/usr/local/go/src/pkg/runtime/proc.c:221
exit status 2
What version of the product are you using? On what operating system?
Please provide any additional information below.
I'm not sure what else to do. The error message seems very helpful. Tells me
what function it's looking for. However, that's exactly the function I have
defined.
Original issue reported on code.google.com by [email protected]
on 22 Apr 2013 at 10:41
Hi,
I am new to golang and also for rest service.
I need more light on how to manage sessions while using gorest.
I came across gorilla toolkit for session management but it reuires the request
response objects which is not expsed in gorest.
Any help in this regard is highly appreciated.
Thank you
Original issue reported on code.google.com by [email protected]
on 8 Nov 2013 at 5:11
I am trying to return type "Creative" from the "get" endpoint. I am getting the
follow stack trace, and my code is below:
STACK TRACE
2012/09/07 12:52:55 Internal Server Error: Could not serve page: GET
/creatives/asf
2012/09/07 12:52:55 runtime error: invalid memory address or nil pointer
dereference
2012/09/07 12:52:55
/usr/local/go/src/pkg/code.google.com/p/gorest/gorest.go:195 (0x81475f6)
google.com/p/gorest._func_001: log.Printf("%s", debug.Stack())
/tmp/bindist374110409/go/src/pkg/runtime/proc.c:1443 (0x80578ab)
/tmp/bindist374110409/go/src/pkg/runtime/runtime.c:128 (0x80582ef)
/tmp/bindist374110409/go/src/pkg/runtime/thread_linux.c:209 (0x805af26)
/usr/local/go/src/pkg/code.google.com/p/gorest/util.go:60 (0x8146492)
google.com/p/gorest.InterfaceToBytes: return m.Marshal(i)
/usr/local/go/src/pkg/code.google.com/p/gorest/reflect.go:406 (0x814542d)
google.com/p/gorest.prepareServe: if bytarr, err := InterfaceToBytes(ret[0].Interface(), servMeta.producesMime); err == nil {
/usr/local/go/src/pkg/code.google.com/p/gorest/gorest.go:215 (0x813ccd4)
google.com/p/gorest.(*manager).ServeHTTP: data, state := prepareServe(ctx, ep)
/usr/local/go/src/pkg/net/http/server.go:926 (0x80a89aa)
(*ServeMux).ServeHTTP: mux.handler(r).ServeHTTP(w, r)
/usr/local/go/src/pkg/net/http/server.go:656 (0x80a7bbd)
(*conn).serve: handler.ServeHTTP(w, w.req)
/tmp/bindist374110409/go/src/pkg/runtime/proc.c:271 (0x8055c29)
CODE
package rest
import (
. "../model"
"code.google.com/p/gorest"
)
type CreativeService struct {
gorest.RestService `root:"/creatives/" consumes:"application/json" produces: "application/json"
get gorest.EndPoint `method:"GET" path:"/{Id:string}" output:"Creative"`
}
func (serv CreativeService) Get(Id string) Creative {
return Creative{Id: "test-id"}
}
Original issue reported on code.google.com by [email protected]
on 7 Sep 2012 at 4:57
It would be great if there were attributes the programmer could include in each
of the Endpoints etc... such that a simple template could render the REST docs.
Original issue reported on code.google.com by [email protected]
on 23 Feb 2013 at 4:38
What steps will reproduce the problem?
Slight modification of the tutorial to add a configuration variable into the
service:
package main
import (
"code.google.com/p/gorest"
"net/http"
)
func main() {
hello := HelloService{greeting: "Nice to see you, "}
gorest.RegisterService(&hello) //Register our service
http.Handle("/", gorest.Handle())
http.ListenAndServe(":8787", nil)
}
//Service Definition
type HelloService struct {
greeting string
gorest.RestService `root:"/tutorial/"`
helloWorld gorest.EndPoint `method:"GET" path:"/hello-world/" output:"string"`
sayHello gorest.EndPoint `method:"GET" path:"/hello/{name:string}" output:"string"`
}
func (serv HelloService) HelloWorld() string {
return "Hello World"
}
func (serv HelloService) SayHello(name string) string {
return serv.greeting + name
}
What is the expected output? What do you see instead?
When I go to: http://localhost:8787/tutorial/hello/andrew I expect to see "Nice
to see you, andrew", but instead I just see "andrew"
Is gorest doing something that prevents me doing this?
Original issue reported on code.google.com by [email protected]
on 12 Jun 2015 at 1:15
Fixed typo when registering services
Original issue reported on code.google.com by [email protected]
on 25 Jun 2013 at 7:40
Attachments:
One should be able to override the default consumes/produces on a per endpoint
basis.
Original issue reported on code.google.com by [email protected]
on 12 Feb 2013 at 3:28
What steps will reproduce the problem?
1. I changed your small working example to read this (note the change in the
output for the helloWorld EndPoint and method):
package main
import (
"code.google.com/p/gorest"
"net/http"
)
func main() {
gorest.RegisterService(new(HelloService)) //Register our service
http.Handle("/",gorest.Handle())
http.ListenAndServe(":8787",nil)
}
//Service Definition
type HelloService struct {
gorest.RestService `root:"/tutorial/"`
helloWorld gorest.EndPoint `method:"GET" path:"/hello-world/" output:"[]byte"`
sayHello gorest.EndPoint `method:"GET" path:"/hello/{name:string}" output:"string"`
}
func(serv HelloService) HelloWorld() []byte{
return nil
}
func(serv HelloService) SayHello(name string) string{
return "Hello " + name
}
2. I compiled and ran the code.
What is the expected output? What do you see instead?
The expected output is the normal output when a service is registered properly.
This is the output I get:
2013/08/13 20:12:34 All EndPoints for service [ HelloService ] , registered
under root path: /tutorial/
2013/08/13 20:12:34 Parameter list not matching. No matching Method found for
EndPoint:[helloWorld],type:[GET] . Expecting: #func(serv HelloService)
HelloWorld()([]byte)# with one([]byte) return parameter.
panic: Parameter list not matching. No matching Method found for
EndPoint:[helloWorld],type:[GET] . Expecting: #func(serv HelloService)
HelloWorld()([]byte)# with one([]byte) return parameter.
goroutine 1 [running]:
log.Panic(0x7fc8c2b73728, 0x1, 0x1)
/usr/lib/go/src/pkg/log/log.go:307 +0xaa
code.google.com/p/gorest.mapFieldsToMethods(0xc20009d000, 0x61b380, 0x64b890,
0xa, 0x63d700, ...)
/home/derrick/Code/Amahi/mercury/src/code.google.com/p/gorest/reflect.go:103 +0x707
code.google.com/p/gorest.registerService(0x6348a0, 0x0, 0x613b20, 0xc2000ac4c0)
/home/derrick/Code/Amahi/mercury/src/code.google.com/p/gorest/reflect.go:66 +0x4e7
code.google.com/p/gorest.RegisterServiceOnPath(0x6348a0, 0x0, 0x613b20,
0xc2000ac4c0)
/home/derrick/Code/Amahi/mercury/src/code.google.com/p/gorest/gorest.go:182 +0x182
code.google.com/p/gorest.RegisterService(0x613b20, 0xc2000ac4c0)
/home/derrick/Code/Amahi/mercury/src/code.google.com/p/gorest/gorest.go:137 +0x46
main.main()
/home/derrick/Code/Amahi/mercury/src/fail/fail.go:13 +0x3c
goroutine 2 [syscall]:
goroutine 3 [runnable]:
What version of the product are you using? On what operating system?
go version go1.1.1 linux/amd64
Please provide any additional information below.
This problem did not show up using Go version 1.0.2 but after upgrading to
1.1.1 this appeared. Gorest shows this problem if byte or []byte is used as a
return type.
Original issue reported on code.google.com by [email protected]
on 14 Aug 2013 at 12:19
any ideas?
Original issue reported on code.google.com by [email protected]
on 16 Aug 2013 at 1:51
2 Problems with xml usage:
1. The wiki says there are marshallers for json and xml but in marshaller.go
there is only the jsonmarshaller predefined
solution: add a predifined xmlmarshaller
2. consumes: application/xml not working even avter adding the marshaller
definition
solution:
parse.go:71 prevented it from working as expected it should be md.producesMime
instead of md.consumesMime in there because md.consumesMime was already set
correctly.
I have fixed both. Maybe integrating it into the repo to have the documented
features?
Original issue reported on code.google.com by [email protected]
on 21 Feb 2013 at 1:49
Attachments:
What steps will reproduce the problem?
1. create a simple rest api with a string argument
2. create GET request with the argument value to ABC2%FDEF
What is the expected output? What do you see instead?
value should be set to ABC/DEF
gorest reports path not found
What version of the product are you using? On what operating system?
latest
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 29 Sep 2013 at 8:58
Fixed a typo in log message.
Original issue reported on code.google.com by [email protected]
on 30 Jul 2013 at 7:13
Attachments:
What steps will reproduce the problem?
1. Create Service Struct
2. Create custom field in addition to endpoint fields
3. Register service
4. Try to use value of field in end point calls
What is the expected output? What do you see instead?
The field value should be set, the custom field is set to nil
What version of the product are you using? On what operating system?
OSX, go 1.2,
Please provide any additional information below.
See Code:
type DeviceService struct {
Registrar sns.Registrar
//Service level config
gorest.RestService `root:"/rest/device/" consumes:"application/json" produces:"application/json"`
registerDevice gorest.EndPoint `method:"POST" path:"/" postdata:"DeviceRegistration"`
}
func (serv DeviceService) RegisterDevice(device DeviceRegistration) {
//The value of registrar is nil when this method is called even though it was set before
log.Printf("Registering Device %v", serv.Registrar)
return
}
Original issue reported on code.google.com by [email protected]
on 30 Dec 2013 at 7:36
What steps will reproduce the problem?
1. set environment variable GOMAXPROCS > 1
2. Take basic hello world example, call ResponseBuilder().AddHeader(...) in
handling function
3. Make many simultaneous requests,
4. some of the responses will get twice the number of headers set, some will
get none.
What version of the product are you using? On what operating system?
go1.1
Please provide any additional information below.
I believe this is causes by setting the 'Context' in 'reflect.go'. Seems like
it's not correctly creating one instantiated service object per one request.
Putting a sleep statement after
'servVal.FieldByName("RestService").FieldByName("Context").Set(reflect.ValueOf(c
ontext))' will clearly show all response headers being sent to the last caller
within the sleep period.
Original issue reported on code.google.com by [email protected]
on 16 Oct 2013 at 7:47
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.