jonike / gorest

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

Setting out of endpoint to type in other package #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 t...@vistarmedia.com on 7 Sep 2012 at 4:57

GoogleCodeExporter commented 9 years ago
Starting work on this over the weekend. Sorry the late start...

Original comment by siyabong...@gmail.com on 13 Dec 2012 at 7:09

GoogleCodeExporter commented 9 years ago
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 siyabong...@gmail.com on 13 Dec 2012 at 8:29

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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 bdemor...@gmail.com on 18 Apr 2013 at 2:49

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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 ch...@altonymous.com on 22 Apr 2013 at 11:29

GoogleCodeExporter commented 9 years ago
This is same as issue #9

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

Original comment by siyabong...@gmail.com on 23 Apr 2013 at 6:56