func RemoveTrailingSlashWithConfig(config TrailingSlashConfig) nio.MiddlewareFunc {
	if config.Skipper == nil {
		config.Skipper = DefaultTrailingSlashConfig.Skipper
	}
	return func(next nio.HandlerFunc) nio.HandlerFunc {
		return func(c nio.Context) error {
			if config.Skipper(c) {
				return next(c)
			}
			req := c.Request()
			url := req.URL
			path := url.Path
			qs := c.QueryString()
			l := len(path) - 1
			if l >= 0 && path != "/" && path[l] == '/' {
				path = path[:l]
				uri := path
				if qs != "" {
					uri += "?" + qs
				}
				if config.RedirectCode != 0 {
					return c.Redirect(config.RedirectCode, uri)
				}
				req.RequestURI = uri
				url.Path = path
			}
			return next(c)
		}
	}
}
RemoveTrailingSlashWithConfig returns a RemoveTrailingSlash middleware with config.
See `RemoveTrailingSlash()`.
package mw
import "github.com/go-nio/nio"
type (
	TrailingSlashConfig struct {
		Skipper nio.Skipper
		RedirectCode int `yaml:"redirect_code"`
	}
)
var (
	DefaultTrailingSlashConfig = TrailingSlashConfig{
		Skipper: nio.DefaultSkipper,
	}
)
func AddTrailingSlash() nio.MiddlewareFunc {
	return AddTrailingSlashWithConfig(DefaultTrailingSlashConfig)
}
func AddTrailingSlashWithConfig(config TrailingSlashConfig) nio.MiddlewareFunc {
	if config.Skipper == nil {
		config.Skipper = DefaultTrailingSlashConfig.Skipper
	}
	return func(next nio.HandlerFunc) nio.HandlerFunc {
		return func(c nio.Context) error {
			if config.Skipper(c) {
				return next(c)
			}
			req := c.Request()
			url := req.URL
			path := url.Path
			qs := c.QueryString()
			if path != "/" && path[len(path)-1] != '/' {
				path += "/"
				uri := path
				if qs != "" {
					uri += "?" + qs
				}
				if config.RedirectCode != 0 {
					return c.Redirect(config.RedirectCode, uri)
				}
				req.RequestURI = uri
				url.Path = path
			}
			return next(c)
		}
	}
}
func RemoveTrailingSlash() nio.MiddlewareFunc {
	return RemoveTrailingSlashWithConfig(TrailingSlashConfig{})
}