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

context.Negotiate does not support application/yaml #3965

Closed
bakito opened this issue May 13, 2024 · 3 comments
Closed

context.Negotiate does not support application/yaml #3965

bakito opened this issue May 13, 2024 · 3 comments

Comments

@bakito
Copy link

bakito commented May 13, 2024

Description

with 1.10.0 support for application/yaml was introduced (#3851)

The Negotiate func of context (https://github.com/gin-gonic/gin/blob/master/context.go#L1179) does not support this content type yet.

How to reproduce

package main

import (
	"github.com/gin-gonic/gin"
)

func main() {
	g := gin.Default()
	g.GET("/hello/:name", func(c *gin.Context) {
			c.Negotiate(http.StatusInternalServerError, gin.Negotiate{
			Offered: []string{binding.MIMEJSON, binding.MIMEYAML2},
			Data:    gin.H{"error": err.Error()},
		})
	})
	g.Run(":9000")
}

Expectations

$ curl -H  "Content-Type: application/yaml" http://localhost:9000/hello/world
# should return status code 500 

Actual result

$ curl -H  "Content-Type: application/yaml" http://localhost:9000/hello/world
# status code 406

Environment

  • go version: 1.22
  • gin version (or commit ref): 1.20.0
  • operating system: ubuntu
@RedCrazyGhost
Copy link
Contributor

Hello, I submitted support for application/yaml judgment logic in Negotiate

@appleboy
Copy link
Member

@bakito Try the latest version.

@bakito
Copy link
Author

bakito commented May 14, 2024

@appleboy I can conform, that my use case is working again when running against the master branch.
@RedCrazyGhost Thank you very much

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

3 participants