Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting out of endpoint to type in other package #2

Open
GoogleCodeExporter opened this issue Apr 20, 2015 · 7 comments
Open

Setting out of endpoint to type in other package #2

GoogleCodeExporter opened this issue Apr 20, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

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

@GoogleCodeExporter
Copy link
Author

Starting work on this over the weekend. Sorry the late start...

Original comment by [email protected] on 13 Dec 2012 at 7:09

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

As a work around, have your model as a package library, then install it into 
go-path and then import it as a full reference... not relative reference.

Original comment by [email protected] on 13 Dec 2012 at 8:29

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

In case anyone else checks this bug out; you will get an almost identical stack 
trace if you forget to specify the 'consumes' and 'produces' attributes inside 
the RestService annotation..

Original comment by [email protected] on 18 Apr 2013 at 2:49

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

I now appear to be getting this same error.  I do not have a relative import 
nor am I missing consumes and products from my Service struct.

I added a comment to my other issue.  #9

Original comment by [email protected] on 22 Apr 2013 at 11:29

@GoogleCodeExporter
Copy link
Author

This is same as issue #9

Could be a a Go bug... see issue #9

Original comment by [email protected] on 23 Apr 2013 at 6:56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant