go-lang-plugin-org/go-lang-idea-plugin

Error to create a custom response

Reti500 opened this issue · 1 comments

  • Plugin version (or commit hash): v0.18.0 (2017-10-30)

  • IDE name and version: Atom, version: 1.23.0

  • Java version: 1.8.0_151

  • OS name and version: macOS High Sierra, version: 10.13 (17A405)

  • What are you trying to do?
    I want create a custom response for controller as describe in the documentation. (https://revel.github.io/manual/results.html#CustomResult).

  • What would you expect to happen?
    I want render a simple text.

  • What happens?
    The first time the request (http://localhost:9000) is executed works successfully, but when reload page this returns 502 error.

Error stack:
INFO 14:06:53 app server.go:2848: http: panic serving 127.0.0.1:51816: runtime error: invalid memory address or nil pointer dereference
goroutine 14 [running]:
net/http.(*conn).serve.func1(0xc4203d6320)
/usr/local/go/src/net/http/server.go:1697 +0xd0
panic(0x14744e0, 0x1775b90)
/usr/local/go/src/runtime/panic.go:491 +0x283
github.com/revel/revel.(*Response).GetWriter(0x0, 0x1509f5e, 0x26)
/Users/rich/golang/src/github.com/revel/revel/http.go:263 +0x26
github.com/revel/revel.(*OutResponse).Write(0xc420081378, 0xc420320330, 0x26, 0x30, 0x26, 0x30, 0xc4204abb38)
/Users/rich/golang/src/github.com/revel/revel/http.go:287 +0x2f
CustomResponse/app/controllers.MyHtml.Apply(0x1509f5e, 0x26, 0xc420114fc0, 0xc420081360)
/Users/rich/golang/src/CustomResponse/app/controllers/app.go:21 +0xa0
CustomResponse/app/controllers.(*MyHtml).Apply(0x1551e30, 0xc420114fc0, 0xc420081360)
:1 +0x59
github.com/revel/revel.handleInternal(0x1744dc0, 0xc420245a20)
/Users/rich/golang/src/github.com/revel/revel/server-engine.go:147 +0x7ef
github.com/revel/revel.(*GoHttpServer).Handle(0xc4201dde90, 0x17480c0, 0xc42033a000, 0xc420338300)
/Users/rich/golang/src/github.com/revel/revel/server_adapter_go.go:101 +0x39e
github.com/revel/revel.(*GoHttpServer).Init.func3(0x17480c0, 0xc42033a000, 0xc420338300)
/Users/rich/golang/src/github.com/revel/revel/server_adapter_go.go:43 +0x48
net/http.HandlerFunc.ServeHTTP(0xc420232a40, 0x17480c0, 0xc42033a000, 0xc420338300)
/usr/local/go/src/net/http/server.go:1918 +0x44
net/http.serverHandler.ServeHTTP(0xc420215e10, 0x17480c0, 0xc42033a000, 0xc420338300)
/usr/local/go/src/net/http/server.go:2619 +0xb4
net/http.(*conn).serve(0xc4203d6320, 0x1748940, 0xc4203b27c0)
/usr/local/go/src/net/http/server.go:1801 +0x71d
created by net/http.(*Server).Serve

My App controller:

package controllers

import (
	"net/http"

	"github.com/revel/revel"
)

type MyHtml string

type App struct {
	*revel.Controller
}

func (c *App) Index() revel.Result {
	return MyHtml("<html><body>Hello Result</body></html>")
}

func (r MyHtml) Apply(req *revel.Request, resp *revel.Response) {
	resp.WriteHeader(http.StatusOK, "text/html")
	resp.Out.Write([]byte(r))
}

Or include a screenshot / video of the issue.

You're using Atom, using something completely unrelated to this plugin, and posting a request for help... on the wrong project... ?