go-zero
go-zero copied to clipboard
feat(rest): add route paths case sensitive option
This pull request adds an option to switch between supporting case sensitive and insensitive router paths.
The options can be set in the YAML configuration file. Defaults to true.
config.yml
Name: HelloWorld
Host: 127.0.0.1
Port: 8080
RoutePathsCaseSensitive: true
After change RoutePathsCaseSensitive to false, /hELLo/wORLD request path should work for below example:
s.AddRoute(rest.Route{
Method: http.MethodGet,
Path: "/hello/world",
Handler: func(writer http.ResponseWriter, request *http.Request) {
httpx.OkJson(writer, "Hello World!")
},
})
Closes #4392
https://www.w3.org/TR/WD-html40-970708/htmlweb.html
URLs in general are case-sensitive (with the exception of machine names). There may be URLs, or parts of URLs, where case doesn't matter, but identifying these may not be easy. Users should always consider that URLs are case-sensitive.
https://www.w3.org/TR/WD-html40-970708/htmlweb.html
URLs in general are case-sensitive (with the exception of machine names). There may be URLs, or parts of URLs, where case doesn't matter, but identifying these may not be easy. Users should always consider that URLs are case-sensitive.
OK, I see. Generally you are right, although I don't know if this is a problematic option. For example, the popular Express.js for Node.js supports case sensitive defined at the Router level: https://expressjs.com/en/5x/api.html#express.router. I thought this could be a useful option.