diff --git a/binding/binding.go b/binding/binding.go index a58924ed..bf0fb1a6 100644 --- a/binding/binding.go +++ b/binding/binding.go @@ -81,7 +81,6 @@ var ( FormMultipart = formMultipartBinding{} ProtoBuf = protobufBinding{} MsgPack = msgpackBinding{} - YAML = yamlBinding{} Uri = uriBinding{} Header = headerBinding{} TOML = tomlBinding{} @@ -103,8 +102,6 @@ func Default(method, contentType string) Binding { return ProtoBuf case MIMEMSGPACK, MIMEMSGPACK2: return MsgPack - case MIMEYAML: - return YAML case MIMETOML: return TOML case MIMEMultipartPOSTForm: diff --git a/binding/binding_test.go b/binding/binding_test.go index f0996216..01f209d3 100644 --- a/binding/binding_test.go +++ b/binding/binding_test.go @@ -163,9 +163,6 @@ func TestBindingDefault(t *testing.T) { assert.Equal(t, ProtoBuf, Default("POST", MIMEPROTOBUF)) assert.Equal(t, ProtoBuf, Default("PUT", MIMEPROTOBUF)) - assert.Equal(t, YAML, Default("POST", MIMEYAML)) - assert.Equal(t, YAML, Default("PUT", MIMEYAML)) - assert.Equal(t, TOML, Default("POST", MIMETOML)) assert.Equal(t, TOML, Default("PUT", MIMETOML)) } @@ -471,27 +468,6 @@ func TestBindingTOMLFail(t *testing.T) { `foo=\n"bar"`, `bar="foo"`) } -func TestBindingYAML(t *testing.T) { - testBodyBinding(t, - YAML, "yaml", - "/", "/", - `foo: bar`, `bar: foo`) -} - -func TestBindingYAMLStringMap(t *testing.T) { - // YAML is a superset of JSON, so the test below is JSON (to avoid newlines) - testBodyBindingStringMap(t, YAML, - "/", "/", - `{"foo": "bar", "hello": "world"}`, `{"nested": {"foo": "bar"}}`) -} - -func TestBindingYAMLFail(t *testing.T) { - testBodyBindingFail(t, - YAML, "yaml", - "/", "/", - `foo:\nbar`, `bar: foo`) -} - func createFormPostRequest(t *testing.T) *http.Request { req, err := http.NewRequest("POST", "/?foo=getfoo&bar=getbar", bytes.NewBufferString("foo=bar&bar=foo")) assert.NoError(t, err) diff --git a/context.go b/context.go index 46bf1133..a9a343fc 100644 --- a/context.go +++ b/context.go @@ -632,11 +632,6 @@ func (c *Context) BindQuery(obj any) error { return c.MustBindWith(obj, binding.Query) } -// BindYAML is a shortcut for c.MustBindWith(obj, binding.YAML). -func (c *Context) BindYAML(obj any) error { - return c.MustBindWith(obj, binding.YAML) -} - // BindTOML is a shortcut for c.MustBindWith(obj, binding.TOML). func (c *Context) BindTOML(obj interface{}) error { return c.MustBindWith(obj, binding.TOML) @@ -695,11 +690,6 @@ func (c *Context) ShouldBindQuery(obj any) error { return c.ShouldBindWith(obj, binding.Query) } -// ShouldBindYAML is a shortcut for c.ShouldBindWith(obj, binding.YAML). -func (c *Context) ShouldBindYAML(obj any) error { - return c.ShouldBindWith(obj, binding.YAML) -} - // ShouldBindTOML is a shortcut for c.ShouldBindWith(obj, binding.TOML). func (c *Context) ShouldBindTOML(obj interface{}) error { return c.ShouldBindWith(obj, binding.TOML) diff --git a/context_test.go b/context_test.go index d09b0ae1..eef6121a 100644 --- a/context_test.go +++ b/context_test.go @@ -1666,23 +1666,6 @@ func TestContextBindWithQuery(t *testing.T) { assert.Equal(t, 0, w.Body.Len()) } -func TestContextBindWithYAML(t *testing.T) { - w := httptest.NewRecorder() - c, _ := CreateTestContext(w) - - c.Request, _ = http.NewRequest("POST", "/", bytes.NewBufferString("foo: bar\nbar: foo")) - c.Request.Header.Add("Content-Type", MIMEXML) // set fake content-type - - var obj struct { - Foo string `yaml:"foo"` - Bar string `yaml:"bar"` - } - assert.NoError(t, c.BindYAML(&obj)) - assert.Equal(t, "foo", obj.Bar) - assert.Equal(t, "bar", obj.Foo) - assert.Equal(t, 0, w.Body.Len()) -} - func TestContextBindWithTOML(t *testing.T) { w := httptest.NewRecorder() c, _ := CreateTestContext(w) @@ -1816,23 +1799,6 @@ func TestContextShouldBindWithQuery(t *testing.T) { assert.Equal(t, 0, w.Body.Len()) } -func TestContextShouldBindWithYAML(t *testing.T) { - w := httptest.NewRecorder() - c, _ := CreateTestContext(w) - - c.Request, _ = http.NewRequest("POST", "/", bytes.NewBufferString("foo: bar\nbar: foo")) - c.Request.Header.Add("Content-Type", MIMEXML) // set fake content-type - - var obj struct { - Foo string `yaml:"foo"` - Bar string `yaml:"bar"` - } - assert.NoError(t, c.ShouldBindYAML(&obj)) - assert.Equal(t, "foo", obj.Bar) - assert.Equal(t, "bar", obj.Foo) - assert.Equal(t, 0, w.Body.Len()) -} - func TestContextShouldBindWithTOML(t *testing.T) { w := httptest.NewRecorder() c, _ := CreateTestContext(w)