@@ -433,6 +433,24 @@ var _ = Describe("RestHandler", func() {
433433 }))
434434 })
435435
436+ It ("POSTSs new objects with trailing slash automatic redirect enabled" , func () {
437+ reqBody := strings .NewReader (`{"posts": [{"title": "New Post"}]}` )
438+ req , err := http .NewRequest ("POST" , "/posts/" , reqBody )
439+ Expect (err ).To (BeNil ())
440+ api .SetRedirectTrailingSlash (true )
441+ api .Handler ().ServeHTTP (rec , req )
442+ Expect (rec .Code ).To (Equal (http .StatusTemporaryRedirect ))
443+ })
444+
445+ It ("POSTSs new objects with trailing slash automatic redirect disabled" , func () {
446+ reqBody := strings .NewReader (`{"posts": [{"title": "New Post"}]}` )
447+ req , err := http .NewRequest ("POST" , "/posts/" , reqBody )
448+ Expect (err ).To (BeNil ())
449+ api .SetRedirectTrailingSlash (false )
450+ api .Handler ().ServeHTTP (rec , req )
451+ Expect (rec .Code ).To (Equal (http .StatusNotFound ))
452+ })
453+
436454 It ("POSTSs multiple objects" , func () {
437455 reqBody := strings .NewReader (`{"posts": [{"title": "New Post"}, {"title" : "Second New Post"}]}` )
438456 req , err := http .NewRequest ("POST" , "/posts" , reqBody )
0 commit comments