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

JSON does not set the correct Content-Type header #10

Closed
pinscript opened this issue Jul 1, 2014 · 2 comments
Closed

JSON does not set the correct Content-Type header #10

pinscript opened this issue Jul 1, 2014 · 2 comments
Assignees
Labels

Comments

@pinscript
Copy link
Contributor

Hi,

I'm experimenting with Gin and stumbled on some problems. The code below does not result in a Content-Type: application/json being set in the response.

func main() {
    r := gin.Default()
    r.GET("/test", func(c *gin.Context) {
        c.JSON(200, gin.H{"status": "you are logged in"})
    })

    r.Run(":8082")
}

Response:

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 6
Date: Tue, 01 Jul 2014 07:13:36 GMT

I've tried fixing the issue myself but i cannot find a way to set a header. All headers are just ignored.

Anyone else experiencing the same problem?

I'm on Go 1.1 on Windows so that might have something to do with it.

@pinscript pinscript changed the title Context.JSON does not set the correct Content-Type header JSON does not set the correct Content-Type header Jul 1, 2014
@pinscript
Copy link
Contributor Author

Update, headers must be set before calling WriteHeader. PR coming.

@javierprovecho
Copy link
Member

PR received, thank you, please keep experimenting. =)

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

No branches or pull requests

2 participants