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

ctx.Write undefined (type *golf.Context has no field or method Write) #30

Open
tablecell opened this issue Aug 16, 2021 · 3 comments
Open

Comments

@tablecell
Copy link

package main

import "github.com/dinever/golf"

func pageHandler(ctx *golf.Context) {
  ctx.Write("Page: " + ctx.Param("page"))
}

func main() {
  app := golf.New()
  app.Get("/p/:page/", pageHandler)
  app.Run(":9000")
}


@bentranter
Copy link
Contributor

Hey @tablecell,

There's no method Write on the *golf.Context struct. You should use Send instead:

package main

import "github.com/dinever/golf"

func pageHandler(ctx *golf.Context) {
    ctx.Send(Page: " + ctx.Param("page"))
}

func main() {
    app := golf.New()
    app.Get("/p/:page/", pageHandler)
    app.Run(":9000")
}

@tablecell
Copy link
Author

@bentranter

code snippets from https://golf.readme.io/docs/context

@tablecell
Copy link
Author

tablecell commented Aug 18, 2021

@bentranter

func mainHandler(ctx *golf.Context) {
	ctx.Send("Hello")
	ctx.Send(" World!")
}

output is Hello
ctx.Send only run once ?

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

No branches or pull requests

2 participants