Skip to content

RemoveTrailingSlash doesn't do anything #650

Description

@alexzorin

Description

The RemoveTrailingSlash middleware does not appear to do what it is meant to do: remove trailing slashes from requests so that the request can be matched by HTTP handlers that omit the trailing slash.

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

Both GET /foo and GET /foo/ should result in HTTP 200 and be served by the HTTP handler.

Actual behaviour

A GET /foo/ results in HTTP 404.

Steps to reproduce

$ go run slashtest.go

$ curl -i localhost:1323/foo
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Wed, 07 Sep 2016 23:58:50 GMT
Content-Length: 13

Hello, World!%                                                                                                         

$ curl -i localhost:1323/foo/
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
Date: Wed, 07 Sep 2016 23:58:52 GMT
Content-Length: 9

Not Found%                                                                                                             

Working code to debug

package main

import (
    "net/http"

    "github.com/labstack/echo"
    "github.com/labstack/echo/engine/standard"
    "github.com/labstack/echo/middleware"
)

func main() {
    e := echo.New()
    e.Use(middleware.RemoveTrailingSlash())

    e.GET("/foo", func(c echo.Context) error {
        return c.String(http.StatusOK, "Hello, World!")
    })

    e.Run(standard.New(":1323"))
}

Version/commit

e980bd9

$ go version
go version go1.7.1 linux/amd64

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions