jonike / gorest

Automatically exported from code.google.com/p/gorest
0 stars 0 forks source link

Gorest throws 'No Matching Method' error when using byte as a return type #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 derrick....@gmail.com on 14 Aug 2013 at 12:19

GoogleCodeExporter commented 9 years ago
I got same issue.

Original comment by linho...@gmail.com on 30 Jul 2014 at 7:13