diff --git a/core/router/api_builder.go b/core/router/api_builder.go index b789bb3b..d9c244e2 100644 --- a/core/router/api_builder.go +++ b/core/router/api_builder.go @@ -488,7 +488,11 @@ func (api *APIBuilder) HandleDir(requestPath, directory string, opts ...DirOptio continue } - requestPath := s.RequestPath[strings.Index(s.RequestPath, api.relativePath)+len(api.relativePath):] + slashIdx := strings.IndexByte(s.RequestPath, '/') + if slashIdx == -1 { + slashIdx = 0 + } + requestPath = s.RequestPath[slashIdx:] routes = append(routes, api.createRoutes([]string{http.MethodGet}, requestPath, h)...) getRoute.StaticSites = append(getRoute.StaticSites, s) } diff --git a/core/router/path.go b/core/router/path.go index 6c32c863..6d9b687a 100644 --- a/core/router/path.go +++ b/core/router/path.go @@ -231,6 +231,11 @@ func splitSubdomainAndPath(fullUnparsedPath string) (subdomain string, path stri return "", "/" } + splitPath := strings.Split(s, ".") + if len(splitPath) == 2 && splitPath[1] == "" { + return splitPath[0] + ".", "/" + } + slashIdx := strings.IndexByte(s, '/') if slashIdx > 0 { // has subdomain diff --git a/core/router/path_test.go b/core/router/path_test.go index 2b2c7538..5e5c6abc 100644 --- a/core/router/path_test.go +++ b/core/router/path_test.go @@ -116,6 +116,8 @@ func TestSplitSubdomainAndPath(t *testing.T) { path string }{ {"admin./users/42", "admin.", "/users/42"}, + {"static.", "static.", "/"}, + {"static./" + WildcardFileParam(), "static.", "/" + WildcardFileParam()}, {"//api/users\\42", "", "/api/users/42"}, {"admin./users//42", "admin.", "/users/42"}, {"*./users/42/", "*.", "/users/42"}, diff --git a/middleware/README.md b/middleware/README.md index b4402aac..46b6f3ec 100644 --- a/middleware/README.md +++ b/middleware/README.md @@ -4,13 +4,14 @@ Builtin Handlers | Middleware | Example | | -----------|-------------| | [basic authentication](basicauth) | [iris/_examples/authentication/basicauth](https://github.com/kataras/iris/tree/master/_examples/authentication/basicauth) | -| [Google reCAPTCHA](recaptcha) | [iris/_examples/miscellaneous/recaptcha](https://github.com/kataras/iris/tree/master/_examples/miscellaneous/recaptcha) | | [localization and internationalization](i18n) | [iris/_examples/miscellaneous/i81n](https://github.com/kataras/iris/tree/master/_examples/miscellaneous/i18n) | | [request logger](logger) | [iris/_examples/http_request/request-logger](https://github.com/kataras/iris/tree/master/_examples/http_request/request-logger) | +| [HTTP method override](methodoverride) | [iris/middleware/methodoverride/methodoverride_test.go](https://github.com/kataras/iris/blob/master/middleware/methodoverride/methodoverride_test.go) | | [profiling (pprof)](pprof) | [iris/_examples/miscellaneous/pprof](https://github.com/kataras/iris/tree/master/_examples/miscellaneous/pprof) | +| [Google reCAPTCHA](recaptcha) | [iris/_examples/miscellaneous/recaptcha](https://github.com/kataras/iris/tree/master/_examples/miscellaneous/recaptcha) | | [recovery](recover) | [iris/_examples/miscellaneous/recover](https://github.com/kataras/iris/tree/master/_examples/miscellaneous/recover) | -Experimental Handlers +Community made ------------ Most of the experimental handlers are ported to work with _iris_'s handler form, from third-party sources. @@ -30,7 +31,7 @@ Most of the experimental handlers are ported to work with _iris_'s handler form, Third-Party Handlers ------------ -iris has its own middleware form of `func(ctx context.Context)` but it's also compatible with all `net/http` middleware forms. See [here](https://github.com/kataras/iris/tree/master/_examples/convert-handlers). +Iris has its own middleware form of `func(ctx context.Context)` but it's also compatible with all `net/http` middleware forms. See [here](https://github.com/kataras/iris/tree/master/_examples/convert-handlers). Here's a small list of useful third-party handlers: diff --git a/middleware/i18n/i18n.go b/middleware/i18n/i18n.go index 260ac83d..3447fbb8 100644 --- a/middleware/i18n/i18n.go +++ b/middleware/i18n/i18n.go @@ -109,7 +109,7 @@ type I18n struct { locales map[string][]*ini.File } -// If `Config.Default` is missing and `Config.Languages` or `Config.Map` contains this key then it will set as the default locale, +// If `Config.Default` is missing and `Config.Languages` or `Config.LanguagesMap` contains this key then it will set as the default locale, // no need to be exported(see `Config.Default`). const defLangCode = "en-US"