嗨,我正在使用 google golang 重置服务我在尝试运行此代码时遇到 post 方法的问题,它显示未定义的 post 数据
package main
import (
"code.google.com/p/gorest"
"fmt"
"net/http"
)
type Invitation struct {
User string
}
//Service Definition
type HelloService struct {
gorest.RestService
//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"`
posted gorest.EndPoint `method:"POST" path:"/post/" postdata:"User" `
}
func main() {
gorest.RegisterService(new(HelloService)) //Register our service
http.Handle("/", gorest.Handle())
http.ListenAndServe(":8787", nil)
}
func (serv HelloService) Posted(posted User) {
fmt.Println(User)
}
func (serv HelloService) HelloWorld() string {
return "Hello World"
}
func (serv HelloService) SayHello(name string) string {
return "Hello " + name
}
这是我得到的错误
# command-line-arguments
./registation.go:28: undefined: User
./registation.go:29: undefined: User
请帮助解决这个问题
谢谢