diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 6f8fbba2..84bbef9a 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,4 +1,4 @@
-- Version : **6.0.9**
+- Version : **6.1.0**
- Operating System:
diff --git a/HISTORY.md b/HISTORY.md
index a03adc91..a3cc0407 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -2,6 +2,12 @@
**How to upgrade**: remove your `$GOPATH/src/github.com/kataras` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`.
+## 6.0.9 -> 6.1.0
+
+- Fix a not found error when serving static files through custom subdomain, this should work again: `iris.Party("mysubdomain.").StaticWeb("/", "./static")`
+
+- Add SPA Example (separate REST API from the index page): https://github.com/iris-contrib/examples/tree/master/spa_1_using_subdomain
+
## 6.0.8 -> 6.0.9
- Add `PostInterrupt` plugin, useful for customization of the **os.Interrupt** singal, before that Iris closed the server automatically.
@@ -19,7 +25,7 @@ iris.Plugins.PostInterrupt(func(s *Framework){
/* Do any custom cleanup and finally call the s.Close()
remember you have the iris.Plugins.PreClose(func(s *Framework)) event too
so you can split your logic in two logically places.
- */
+ */
})
diff --git a/README.md b/README.md
index 349e8567..4d99c02a 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@
-
+
@@ -947,7 +947,7 @@ I recommend testing your API using this new library, [httpexpect](https://github
Versioning
------------
-Current: **v6.0.9**
+Current: **v6.1.0**
Older: **[v5/fasthttp](https://github.com/kataras/iris/tree/5.0.0)**
diff --git a/iris.go b/iris.go
index c870b75f..3abab865 100644
--- a/iris.go
+++ b/iris.go
@@ -81,7 +81,7 @@ const (
// IsLongTermSupport flag is true when the below version number is a long-term-support version
IsLongTermSupport = false
// Version is the current version number of the Iris web framework
- Version = "6.0.9"
+ Version = "6.1.0"
banner = ` _____ _
|_ _| (_)
@@ -577,6 +577,14 @@ func (s *Framework) Listen(addr string) {
s.Config.VHost = addr
// this will be set as the front-end listening addr
}
+ // only here, other Listen functions should throw an error if port is missing.
+ // User should know how to fix them on ListenUNIX/ListenTLS/ListenLETSENCRYPT/Serve,
+ // they are used by more 'advanced' devs, mostly.
+
+ if portIdx := strings.IndexByte(addr, ':'); portIdx < 0 {
+ // missing port part, add it
+ addr = addr + ":80"
+ }
ln, err := TCPKeepAlive(addr)
if err != nil {
@@ -1394,60 +1402,6 @@ func (api *muxAPI) DoneFunc(handlersFn ...HandlerFunc) MuxAPI {
return api.Done(convertToHandlers(handlersFn)...)
}
-// UseTransaction adds transaction(s) middleware
-// the difference from manually adding them to the ctx.BeginTransaction
-// is that if a transaction is requested scope and is failed then the (next) handler is not executed.
-//
-// Returns itself.
-//
-// See https://github.com/iris-contrib/examples/tree/master/transactions to manually add transactions
-// and https://github.com/kataras/iris/blob/master/context_test.go for more
-// func UseTransaction(pipes ...TransactionFunc) MuxAPI {
-// return Default.UseTransaction(pipes...)
-// }
-
-// UseTransaction adds transaction(s) middleware
-// the difference from manually adding them to the ctx.BeginTransaction
-// is that if a transaction is requested scope and is failed then the (next) handler is not executed.
-//
-// Returns itself.
-//
-// See https://github.com/iris-contrib/examples/tree/master/transactions to manually add transactions
-// and https://github.com/kataras/iris/blob/master/context_test.go for more
-// func (api *muxAPI) UseTransaction(pipes ...TransactionFunc) MuxAPI {
-// return api.UseFunc(func(ctx *Context) {
-// for i := range pipes {
-// ctx.BeginTransaction(pipes[i])
-// if ctx.TransactionsSkipped() {
-// ctx.StopExecution()
-// }
-// }
-// ctx.Next()
-// })
-// }
-
-// DoneTransaction registers Transaction 'middleware' the only difference from .UseTransaction is that
-// is executed always last, after all of each route's handlers, returns itself.
-//
-// See https://github.com/iris-contrib/examples/tree/master/transactions to manually add transactions
-// and https://github.com/kataras/iris/blob/master/context_test.go for more
-// func DoneTransaction(pipes ...TransactionFunc) MuxAPI {
-// return Default.DoneTransaction(pipes...)
-// }
-
-// DoneTransaction registers Transaction 'middleware' the only difference from .UseTransaction is that
-// is executed always last, after all of each route's handlers, returns itself.
-//
-// See https://github.com/iris-contrib/examples/tree/master/transactions to manually add transactions
-// and https://github.com/kataras/iris/blob/master/context_test.go for more
-// func (api *muxAPI) DoneTransaction(pipes ...TransactionFunc) MuxAPI {
-// return api.DoneFunc(func(ctx *Context) {
-// for i := range pipes {
-// ctx.BeginTransaction(pipes[i])
-// }
-// })
-// }
-
// Handle registers a route to the server's router
// if empty method is passed then registers handler(s) for all methods, same as .Any, but returns nil as result
func Handle(method string, registeredPath string, handlers ...Handler) RouteNameFunc {
@@ -1504,6 +1458,7 @@ func (api *muxAPI) Handle(method string, registeredPath string, handlers ...Hand
middleware = append(middleware, api.doneMiddleware...) // register the done middleware, if any
}
r := api.mux.register(method, subdomain, path, middleware)
+
api.apiRoutes = append(api.apiRoutes, r)
// should we remove the api.apiRoutes on the .Party (new children party) ?, No, because the user maybe use this party later
@@ -2032,8 +1987,16 @@ func StaticHandler(reqPath string, systemPath string, showList bool, enableGzip
// StaticHandler returns a new Handler which serves static files
func (api *muxAPI) StaticHandler(reqPath string, systemPath string, showList bool, enableGzip bool) HandlerFunc {
+ // here we separate the path from the subdomain (if any), we care only for the path
+ // fixes a bug when serving static files via a subdomain
+ fullpath := api.relativePath + reqPath
+ path := fullpath
+ if dotWSlashIdx := strings.Index(path, subdomainIndicator); dotWSlashIdx > 0 {
+ path = fullpath[dotWSlashIdx+1:]
+ }
+
h := NewStaticHandlerBuilder(systemPath).
- Path(api.relativePath + reqPath).
+ Path(path).
Listing(showList).
Gzip(enableGzip).
Build()