From 7fd8baea754f2d3e452d318d5d7961fb4d093a35 Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Mon, 12 Feb 2018 04:04:46 +0200 Subject: [PATCH 1/4] README.md: make backers visible on the top of the page, replaced the prev api to the https://iris-go.com/backers.svg in order this to happens Former-commit-id: 093f11d05fe9556c79de2cb2886e5d0569f27336 --- .github/ISSUE_TEMPLATE.md | 3 +-- CONTRIBUTING.md | 15 +++----------- README.md | 4 ++-- README_GR.md | 4 ++-- README_RU.md | 4 ++-- README_ZH.md | 4 ++-- _examples/http_request/read-json/main.go | 20 +++++++++++++++++++ _examples/routing/reverse/main.go | 5 ++++- _examples/view/template_html_4/main.go | 6 ++++++ .../view/template_html_4/templates/page.html | 14 +++++++++++++ 10 files changed, 56 insertions(+), 23 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index e03f3558..5fc7c444 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -4,6 +4,5 @@ Examples for the Iris project can be found at Documentation for the Iris project can be found at . -Love iris? Please consider supporting our collective: -👉 https://opencollective.com/iris/donate +Love iris? Please consider supporting the project: 👉 https://iris-go.com/donate \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 33d7b9c0..e8c1cb38 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,24 +77,15 @@ If you want to be part of this and you've time for collaboration, please open a All new contributors of that book will receive prizes! -## Financial contributions - -We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/iris). -Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed. - -## Credits - - ### Contributors -Thank you to all the people who have already contributed to iris! - +Thank you to all the people who have already contributed to Iris! ### Backers -Thank you to all our backers! [Become a backer](https://opencollective.com/iris#backer) +Thank you to all our backers! [Become a backer](https://iris-go.com/donate) - + ### Sponsors diff --git a/README.md b/README.md index 18d96ac9..c97cd6fb 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ Learn what [others say about Iris](#support) and [star](https://github.com/katar ## Backers -Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/iris#backer) +Thank you to all our backers! 🙏 [Become a backer](https://iris-go.com/donate) - + ```sh $ cat example.go diff --git a/README_GR.md b/README_GR.md index 365ef6af..44573314 100644 --- a/README_GR.md +++ b/README_GR.md @@ -14,9 +14,9 @@ ## Yποστηρικτές -Eυχαριστούμε όλους τους υποστηρικτές μας! 🙏 [Γίνετε ένας από αυτούς](https://opencollective.com/iris#backer) +Eυχαριστούμε όλους τους υποστηρικτές μας! 🙏 [Γίνετε ένας από αυτούς](https://iris-go.com/donate) - + ```sh $ cat example.go diff --git a/README_RU.md b/README_RU.md index 3476ecab..8c400c87 100644 --- a/README_RU.md +++ b/README_RU.md @@ -14,9 +14,9 @@ Iris предоставляет красиво выразительную и у ## Сторонники -Спасибо всем, кто поддерживал нас! 🙏 [Поддержать нас](https://opencollective.com/iris#backer) +Спасибо всем, кто поддерживал нас! 🙏 [Поддержать нас](https://iris-go.com/donate) - + ```sh $ cat example.go diff --git a/README_ZH.md b/README_ZH.md index 1f3930d9..2277d732 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -14,9 +14,9 @@ Iris 功能强大、使用简单,它将会是你下一个网站、API 服务 ## 支持者 -感谢所有的支持者! 🙏 [支持我们](https://opencollective.com/iris#backer) +感谢所有的支持者! 🙏 [支持我们](https://iris-go.com/donate) - + ```sh $ cat example.go diff --git a/_examples/http_request/read-json/main.go b/_examples/http_request/read-json/main.go index b90f9da7..fb4ff396 100644 --- a/_examples/http_request/read-json/main.go +++ b/_examples/http_request/read-json/main.go @@ -21,10 +21,30 @@ func MyHandler(ctx iris.Context) { ctx.Writef("Received: %#v\n", c) } +type Person struct { + Name string `json:"name"` + Age int `json:"age"` +} + +// MyHandler2 reads a collection of Person from JSON post body. +func MyHandler2(ctx iris.Context) { + var persons []Person + err := ctx.ReadJSON(&persons) + + if err != nil { + ctx.StatusCode(iris.StatusBadRequest) + ctx.WriteString(err.Error()) + return + } + + ctx.Writef("Received: %#+v\n", persons) +} + func main() { app := iris.New() app.Post("/", MyHandler) + app.Post("/slice", MyHandler2) // use Postman or whatever to do a POST request // to the http://localhost:8080 with RAW BODY: diff --git a/_examples/routing/reverse/main.go b/_examples/routing/reverse/main.go index 7867be86..1ab53c11 100644 --- a/_examples/routing/reverse/main.go +++ b/_examples/routing/reverse/main.go @@ -32,6 +32,9 @@ func main() { // http://localhost:8080/reverse_myroute // http://localhost:8080/execute_myroute // http://localhost:8080/anything/any/path/here + // + // See view/template_html_4 example for more reverse routing examples + // using the reverse router component and the {{url}} and {{urlpath}} template functions. app.Run(iris.Addr(":8080")) -} // See view/template_html_4 example for more. +} diff --git a/_examples/view/template_html_4/main.go b/_examples/view/template_html_4/main.go index a15a4d18..4484adf8 100644 --- a/_examples/view/template_html_4/main.go +++ b/_examples/view/template_html_4/main.go @@ -56,6 +56,12 @@ func main() { } }) + // simple path so you can test it without host mapping and subdomains, + // at view it make uses of {{urlpath ...}} + // in order to showcase you that you can use it + // if you don't want the entire scheme and host to be part of the url. + app.Get("/mypath7/{paramfirst}/{paramsecond}/static/{paramthird}", emptyHandler).Name = "my-page7" + // http://127.0.0.1:8080 app.Run(iris.Addr(host)) } diff --git a/_examples/view/template_html_4/templates/page.html b/_examples/view/template_html_4/templates/page.html index f4f605be..9e35dc37 100644 --- a/_examples/view/template_html_4/templates/page.html +++ b/_examples/view/template_html_4/templates/page.html @@ -4,26 +4,40 @@ is the subdomain part instead of named parameter--> username1.127.0.0.1:8080/mypath

+ username2.127.0.0.1:8080/mypath2/{paramfirst}/{paramsecond}

+ username3.127.0.0.1:8080/mypath3/{paramfirst}/statichere/{paramsecond}

+ username4.127.0.0.1:8080/mypath4/{paramfirst}/statichere/{paramsecond}/{otherParam}/{something:path}

+ username5.127.0.0.1:8080/mypath5/{paramfirst}/statichere/{paramsecond}/{otherparam}/anything/{something:path}

+ username5.127.0.0.1:8080/mypath6/{paramfirst}/{paramsecond}/staticParam/{paramThirdAfterStatic} +
+
+ + + mypath7/{paramfirst}/{paramsecond}/static/{paramthird} + +
+
+ From fce79594244cc4a4dd49a4bf6b2407cb36232c2d Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Mon, 12 Feb 2018 06:03:15 +0200 Subject: [PATCH 2/4] remove old deprecated code from previous version, no need to keep backward compatibility, it was two months ago v10.0.0 released so we should be ok now Former-commit-id: 81ac9d4913e78154b4bb74a01ce707b510e674ec --- core/maintenance/authenticate.go | 93 ------------------------ core/maintenance/client/client.go | 46 ------------ core/maintenance/encoding/unmarshaler.go | 33 --------- core/maintenance/version.go | 19 ++--- deprecated.go | 54 -------------- 5 files changed, 5 insertions(+), 240 deletions(-) delete mode 100644 core/maintenance/authenticate.go delete mode 100644 core/maintenance/client/client.go delete mode 100644 core/maintenance/encoding/unmarshaler.go diff --git a/core/maintenance/authenticate.go b/core/maintenance/authenticate.go deleted file mode 100644 index e4dc1168..00000000 --- a/core/maintenance/authenticate.go +++ /dev/null @@ -1,93 +0,0 @@ -package maintenance - -import ( - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/url" - - "github.com/kataras/iris/core/maintenance/client" - "github.com/kataras/iris/core/maintenance/encoding" - - "github.com/kataras/survey" -) - -// question describes the question which will be used -// for the survey in order to authenticate the local iris. -type question struct { - Message string `json:"message"` -} - -func hasInternetConnection() (bool, bool) { - r, err := client.PostForm("", nil) - if err != nil { - // no internet connection - return false, false - } - defer r.Body.Close() - return true, r.StatusCode == 204 -} - -func ask() bool { - qs := fetchQuestions() - var lastResponseUnsed string - for _, q := range qs { - survey.AskOne(&survey.Input{Message: q.Message}, &lastResponseUnsed, validate(q)) - } - - return lastResponseUnsed != "" -} - -// fetchQuestions returns a list of questions -// fetched by the authority server. -func fetchQuestions() (qs []question) { - r, err := client.PostForm("/survey/ask", nil) - if err != nil { - return - } - defer r.Body.Close() - if err := encoding.UnmarshalBody(r.Body, &qs, json.Unmarshal); err != nil { - return - } - - return -} - -func validate(q question) survey.Validator { - return func(answer interface{}) error { - if err := survey.Required(answer); err != nil { - return err - } - - ans, ok := answer.(string) - if !ok { - return fmt.Errorf("bug: expected string but got %v", answer) - } - data := url.Values{ - "q": []string{q.Message}, - "ans": []string{ans}, - "current_version": []string{Version}, - } - - r, err := client.PostForm("/survey/submit", data) - if err != nil { - // error from server-side, allow. - return nil - } - defer r.Body.Close() - - if r.StatusCode == 200 { - // read the whole thing, it has nothing. - io.Copy(ioutil.Discard, r.Body) - return nil // pass, no any errors. - } - // now, if invalid; - got, err := ioutil.ReadAll(r.Body) - if err != nil { - return nil - } - errMsg := string(got) - return fmt.Errorf(errMsg) - } -} diff --git a/core/maintenance/client/client.go b/core/maintenance/client/client.go deleted file mode 100644 index 382ade84..00000000 --- a/core/maintenance/client/client.go +++ /dev/null @@ -1,46 +0,0 @@ -package client - -import ( - "bytes" - "net" - "net/http" - "net/url" - "os/user" - "time" - - "github.com/kataras/iris/core/netutil" -) - -const host = "https://live.iris-go.com" - -// PostForm performs the PostForm with a secure client. -func PostForm(p string, data url.Values) (*http.Response, error) { - client := netutil.Client(25 * time.Second) - - if len(data) == 0 { - data = make(url.Values, 1) - } - un, _ := user.Current() - if un != nil { - a += "_" + un.Name - } - data.Set("X-Auth", url.QueryEscape(a)) - - u := host + p - r, err := client.PostForm(u, data) - return r, err -} - -var a string - -func init() { - interfaces, err := net.Interfaces() - if err == nil { - for _, f := range interfaces { - if f.Flags&net.FlagUp != 0 && bytes.Compare(f.HardwareAddr, nil) != 0 { - a = f.HardwareAddr.String() - break - } - } - } -} diff --git a/core/maintenance/encoding/unmarshaler.go b/core/maintenance/encoding/unmarshaler.go deleted file mode 100644 index 04793bc8..00000000 --- a/core/maintenance/encoding/unmarshaler.go +++ /dev/null @@ -1,33 +0,0 @@ -package encoding - -import ( - "errors" - "io" - "io/ioutil" - "reflect" -) - -// UnmarshalerFunc is the Unmarshaler compatible type. -// -// See 'unmarshalBody' for more. -type UnmarshalerFunc func(data []byte, v interface{}) error - -// UnmarshalBody reads the request's body and binds it to a value or pointer of any type. -func UnmarshalBody(body io.Reader, v interface{}, unmarshaler UnmarshalerFunc) error { - if body == nil { - return errors.New("unmarshal: empty body") - } - - rawData, err := ioutil.ReadAll(body) - if err != nil { - return err - } - - // check if v is already a pointer, if yes then pass as it's - if reflect.TypeOf(v).Kind() == reflect.Ptr { - return unmarshaler(rawData, v) - } - // finally, if the v doesn't contains a self-body decoder and it's not a pointer - // use the custom unmarshaler to bind the body - return unmarshaler(rawData, &v) -} diff --git a/core/maintenance/version.go b/core/maintenance/version.go index fd16b8d2..8f14615b 100644 --- a/core/maintenance/version.go +++ b/core/maintenance/version.go @@ -19,34 +19,25 @@ const ( // CheckForUpdates checks for any available updates // and asks for the user if want to update now or not. func CheckForUpdates(ft bool) { - has := true - if ft { - has, ft = hasInternetConnection() - } - v := version.Acquire() updateAvailale := v.Compare(Version) == version.Smaller if updateAvailale { if confirmUpdate(v) { - canUpdate := (has && ft && ask()) || !has || !ft - if canUpdate { - installVersion() - } + installVersion() + return } } } func confirmUpdate(v version.Version) bool { - // on help? when asking for installing the new update - // and when answering "No". + // on help? when asking for installing the new update. ignoreUpdatesMsg := "Would you like to ignore future updates? Disable the version checker via:\napp.Run(..., iris.WithoutVersionChecker)" // if update available ask for update action. shouldUpdateNowMsg := - fmt.Sprintf("A new version is available online[%s < %s].\nRelease notes: %s.\nUpdate now?", - Version, v.String(), - v.ChangelogURL) + fmt.Sprintf("A new version is available online[%s > %s]. Type '?' for help.\nRelease notes: %s.\nUpdate now?", + v.String(), Version, v.ChangelogURL) var confirmUpdate bool survey.AskOne(&survey.Confirm{ diff --git a/deprecated.go b/deprecated.go index 744684ec..d44707b2 100644 --- a/deprecated.go +++ b/deprecated.go @@ -1,55 +1 @@ package iris - -import ( - "fmt" - - "github.com/kataras/iris/core/router" - "github.com/kataras/iris/mvc" -) - -// Controller method is DEPRECATED, use the "mvc" subpackage instead, i.e -// import "github.com/kataras/iris/mvc" and read its docs among with its new features at: -// https://github.com/kataras/iris/blob/master/HISTORY.md#mo-01-jenuary-2018--v1000 -func (app *Application) Controller(relPath string, c interface{}, _ ...interface{}) []*router.Route { - name := mvc.NameOf(c) - - panic(fmt.Errorf(`"Controller" method is DEPRECATED, use the "mvc" subpackage instead. - - PREVIOUSLY YOU USED TO CODE IT LIKE THIS: - - import ( - "github.com/kataras/iris" - // ... - ) - - app.Controller("%s", new(%s), Struct_Values_Binded_To_The_Fields_Or_And_Any_Middleware) - - NOW YOU SHOULD CODE IT LIKE THIS: - - import ( - "github.com/kataras/iris" - "github.com/kataras/iris/mvc" - // ... - ) - - // or use it like this: ).Register(...).Handle(new(%s)) - mvc.Configure(app.Party("%s"), myMVC) - - func myMVC(mvcApp *mvc.Application) { - mvcApp.Register( - Struct_Values_Dependencies_Binded_To_The_Fields_Or_And_To_Methods, - Or_And_Func_Values_Dependencies_Binded_To_The_Fields_Or_And_To_Methods, - ) - - mvcApp.Router.Use(Any_Middleware) - - mvcApp.Handle(new(%s)) - } - - The new MVC implementation contains a lot more than the above, - this is the reason you see more lines for a simple controller. - - Please read more about the newest, amazing, features by navigating below - https://github.com/kataras/iris/blob/master/HISTORY.md#mo-01-jenuary-2018--v1000`, // v10.0.0, we skip the number 9. - relPath, name, name, relPath, name)) -} From ffc3ec86ae6085a12d9803c606cbe53fcf9e9041 Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Mon, 12 Feb 2018 06:10:57 +0200 Subject: [PATCH 3/4] README.md: change the link of 'learn by examples' to the https://iris-go.com/v10/recipe, the page there is always up-to-date with the _examples folder of the repository, automated. Former-commit-id: 51db560d5d542662accb7cd894a944abddb052f7 --- README.md | 4 ++-- README_GR.md | 4 ++-- README_RU.md | 4 ++-- README_ZH.md | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c97cd6fb..9cf356f5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Iris Web Framework - + -[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=flat-square)](https://travis-ci.org/kataras/iris) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris) [![vscode-iris](https://img.shields.io/badge/ext%20-vscode-0c77e3.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=kataras2006.iris) [![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris) [![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](_examples/) [![release](https://img.shields.io/badge/release%20-v10.2-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/releases) +[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=flat-square)](https://travis-ci.org/kataras/iris) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris) [![vscode-iris](https://img.shields.io/badge/ext%20-vscode-0c77e3.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=kataras2006.iris) [![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris) [![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](https://iris-go.com/v10/recipe) [![release](https://img.shields.io/badge/release%20-v10.2-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/releases) Iris is a fast, simple yet fully featured and very efficient web framework for Go. diff --git a/README_GR.md b/README_GR.md index 44573314..fb6a7f68 100644 --- a/README_GR.md +++ b/README_GR.md @@ -1,8 +1,8 @@ # Iris Web Framework - + -[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=flat-square)](https://travis-ci.org/kataras/iris) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris) [![vscode-iris](https://img.shields.io/badge/ext%20-vscode-0c77e3.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=kataras2006.iris) [![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris) [![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](_examples/) [![release](https://img.shields.io/badge/release%20-v10.2-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/releases) +[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=flat-square)](https://travis-ci.org/kataras/iris) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris) [![vscode-iris](https://img.shields.io/badge/ext%20-vscode-0c77e3.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=kataras2006.iris) [![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris) [![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](https://iris-go.com/v10/recipe) [![release](https://img.shields.io/badge/release%20-v10.2-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/releases) Το Iris είναι ένα γρήγορο, απλό αλλά και πλήρως λειτουργικό και πολύ αποδοτικό web framework για τη Go. diff --git a/README_RU.md b/README_RU.md index 8c400c87..e7eae61d 100644 --- a/README_RU.md +++ b/README_RU.md @@ -1,8 +1,8 @@ # Iris Web Framework - + -[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=flat-square)](https://travis-ci.org/kataras/iris) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris) [![vscode-iris](https://img.shields.io/badge/ext%20-vscode-0c77e3.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=kataras2006.iris) [![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris) [![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](_examples/) [![release](https://img.shields.io/badge/release%20-v10.2-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/releases) +[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=flat-square)](https://travis-ci.org/kataras/iris) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris) [![vscode-iris](https://img.shields.io/badge/ext%20-vscode-0c77e3.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=kataras2006.iris) [![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris) [![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](https://iris-go.com/v10/recipe) [![release](https://img.shields.io/badge/release%20-v10.2-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/releases) Iris - это быстрая, простая, но полнофункциональная и очень эффективная веб-платформа для Go. diff --git a/README_ZH.md b/README_ZH.md index 2277d732..43952d41 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,8 +1,8 @@ # Iris Web Framework - + -[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=flat-square)](https://travis-ci.org/kataras/iris) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris) [![vscode-iris](https://img.shields.io/badge/ext%20-vscode-0c77e3.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=kataras2006.iris) [![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris) [![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](_examples/) [![release](https://img.shields.io/badge/release%20-v10.2-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/releases) +[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=flat-square)](https://travis-ci.org/kataras/iris) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris) [![vscode-iris](https://img.shields.io/badge/ext%20-vscode-0c77e3.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=kataras2006.iris) [![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris) [![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](https://iris-go.com/v10/recipe) [![release](https://img.shields.io/badge/release%20-v10.2-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/releases) Iris 是一款超快、简洁高效的 Go 语言 Web开发框架。 From d4993e6a3f12e05da24f4bfc033cc9bccae88785 Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Thu, 15 Feb 2018 13:01:13 +0200 Subject: [PATCH 4/4] Update to version 10.2.1 - fix StaticEmbedded & StaticWeb when served from a subdomain. Read https://github.com/kataras/iris/blob/master/HISTORY.md#th-15-february-2018--v1021 Former-commit-id: 9bc3ed63fadbb4fb38abef06115b5d6d760256f0 --- HISTORY.md | 4 ++++ HISTORY_GR.md | 6 ++++++ HISTORY_ZH.md | 4 ++++ README.md | 2 +- README_GR.md | 2 +- README_RU.md | 2 +- README_ZH.md | 2 +- VERSION | 2 +- core/maintenance/version.go | 2 +- core/router/api_builder.go | 24 ++++++++++++++++++------ 10 files changed, 38 insertions(+), 12 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index f9c5331c..c3216d7a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -17,6 +17,10 @@ Developers are not forced to upgrade if they don't really need it. Upgrade whene **How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris` or let the automatic updater do that for you. +# Th, 15 February 2018 | v10.2.1 + +Fix subdomains' `StaticEmbedded` & `StaticWeb` not found errors, as reported by [@speedwheel](https://github.com/speedwheel) via [facebook page's chat](https://facebook.com/iris.framework). + # Th, 08 February 2018 | v10.2.0 A new minor version family because it contains a **BREAKING CHANGE** and a new `Party#Reset` function. diff --git a/HISTORY_GR.md b/HISTORY_GR.md index 52a6f5bd..ca3e398a 100644 --- a/HISTORY_GR.md +++ b/HISTORY_GR.md @@ -17,6 +17,12 @@ **Πώς να αναβαθμίσετε**: Ανοίξτε την γραμμή εντολών σας και εκτελέστε αυτήν την εντολή: `go get -u github.com/kataras/iris` ή αφήστε το αυτόματο updater να το κάνει αυτό για σας. +# Th, 15 February 2018 | v10.2.1 + +Διόρθωση το οποίο αφορά 404 not found errors στα αρχεία που σερβίρονται από τα `StaticEmbedded` και `StaticWeb` των υποτομεών(subdomains), όπως αναφέρθηκε πριν λίγο από τον [@speedwheel](https://github.com/speedwheel) μέσω [της σελίδας μας στο facebook](https://facebook.com/iris.framework). + +This history entry is not yet translated to Greek. Please read [the english version instead](https://github.com/kataras/iris/blob/master/HISTORY.md#th-15-february-2018--v1021). + # Th, 08 February 2018 | v10.2.0 This history entry is not yet translated to Greek. Please read [the english version instead](https://github.com/kataras/iris/blob/master/HISTORY.md#th-08-february-2018--v1020). diff --git a/HISTORY_ZH.md b/HISTORY_ZH.md index 1888e196..f65e0c34 100644 --- a/HISTORY_ZH.md +++ b/HISTORY_ZH.md @@ -17,6 +17,10 @@ **如何升级**: 打开命令行执行以下命令: `go get -u github.com/kataras/iris` 或者等待自动更新。 +# Th, 15 February 2018 | v10.2.1 + +This history entry is not yet translated to Chinese. Please read [the english version instead](https://github.com/kataras/iris/blob/master/HISTORY.md#th-15-february-2018--v1021). + # 2018 2月8号 | v10.2.0 版本更新 新的小版本, 因为它包含一个 **破坏性变动** 和一个新功能 `Party#Reset` diff --git a/README.md b/README.md index 9cf356f5..096c1e6d 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ _Updated at: [Tuesday, 21 November 2017](_benchmarks/README_UNIX.md)_ ## Support -- [HISTORY](HISTORY.md#th-08-february-2018--v1020) file is your best friend, it contains information about the latest features and changes +- [HISTORY](HISTORY.md#th-15-february-2018--v1021) file is your best friend, it contains information about the latest features and changes - Did you happen to find a bug? Post it at [github issues](https://github.com/kataras/iris/issues) - Do you have any questions or need to speak with someone experienced to solve a problem at real-time? Join us to the [community chat](https://chat.iris-go.com) - Complete our form-based user experience report by clicking [here](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link) diff --git a/README_GR.md b/README_GR.md index fb6a7f68..f9277217 100644 --- a/README_GR.md +++ b/README_GR.md @@ -108,7 +108,7 @@ _Η τελευταία ενημέρωση έγινε την [Τρίτη, 21 Νο ## Υποστήριξη -- To [HISTORY](HISTORY_GR.md#th-08-february-2018--v1020) αρχείο είναι ο καλύτερος σας φίλος, περιέχει πληροφορίες σχετικά με τις τελευταίες λειτουργίες(features) και αλλαγές +- To [HISTORY](HISTORY_GR.md#th-15-february-2018--v1021) αρχείο είναι ο καλύτερος σας φίλος, περιέχει πληροφορίες σχετικά με τις τελευταίες λειτουργίες(features) και αλλαγές - Μήπως τυχαίνει να βρήκατε κάποιο bug; Δημοσιεύστε το στα [github issues](https://github.com/kataras/iris/issues) - Έχετε οποιεσδήποτε ερωτήσεις ή πρέπει να μιλήσετε με κάποιον έμπειρο για την επίλυση ενός προβλήματος σε πραγματικό χρόνο; Ελάτε μαζί μας στην [συνομιλία κοινότητας](https://chat.iris-go.com) - Συμπληρώστε την αναφορά εμπειρίας χρήστη κάνοντας κλικ [εδώ](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link) diff --git a/README_RU.md b/README_RU.md index e7eae61d..aaa29ad4 100644 --- a/README_RU.md +++ b/README_RU.md @@ -106,7 +106,7 @@ _Обновлено: [Вторник, 21 ноября 2017 г.](_benchmarks/READ ## Поддержка -- Файл [HISTORY](HISTORY.md#th-08-february-2018--v1020) - ваш лучший друг, он содержит информацию о последних особенностях и всех изменениях +- Файл [HISTORY](HISTORY.md#th-15-february-2018--v1021) - ваш лучший друг, он содержит информацию о последних особенностях и всех изменениях - Вы случайно обнаружили ошибку? Опубликуйте ее на [Github вопросы](https://github.com/kataras/iris/issues) - У Вас есть какие-либо вопросы или Вам нужно поговорить с кем-то, кто бы смог решить Вашу проблему в режиме реального времени? Присоединяйтесь к нам в [чате сообщества](https://chat.iris-go.com) - Заполните наш отчет о пользовательском опыте на основе формы, нажав [здесь](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link) diff --git a/README_ZH.md b/README_ZH.md index 43952d41..cebf49ae 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -102,7 +102,7 @@ _更新于: [2017年11月21日星期二](_benchmarks/README_UNIX.md)_ ## 支持 -- [更新记录](HISTORY_ZH.md#th-08-february-2018--v1020) 是您最好的朋友,它包含有关最新功能和更改的信息 +- [更新记录](HISTORY_ZH.md#th-15-february-2018--v1021) 是您最好的朋友,它包含有关最新功能和更改的信息 - 你碰巧找到了一个错误? 请提交 [github issues](https://github.com/kataras/iris/issues) - 您是否有任何疑问或需要与有经验的人士交谈以实时解决问题? [加入我们的聊天](https://chat.iris-go.com) - [点击这里完成我们基于表单的用户体验报告](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link) diff --git a/VERSION b/VERSION index b59967f3..b2996f61 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.2.0:https://github.com/kataras/iris/blob/master/HISTORY.md#th-08-february-2018--v1020 \ No newline at end of file +10.2.1:https://github.com/kataras/iris/blob/master/HISTORY.md#th-15-february-2018--v1021 \ No newline at end of file diff --git a/core/maintenance/version.go b/core/maintenance/version.go index 8f14615b..82648e6e 100644 --- a/core/maintenance/version.go +++ b/core/maintenance/version.go @@ -13,7 +13,7 @@ import ( const ( // Version is the string representation of the current local Iris Web Framework version. - Version = "10.2.0" + Version = "10.2.1" ) // CheckForUpdates checks for any available updates diff --git a/core/router/api_builder.go b/core/router/api_builder.go index da366245..e9afefba 100644 --- a/core/router/api_builder.go +++ b/core/router/api_builder.go @@ -617,6 +617,12 @@ func (api *APIBuilder) StaticEmbeddedHandler(vdir string, assetFn func(name stri // Examples: https://github.com/kataras/iris/tree/master/_examples/file-server func (api *APIBuilder) StaticEmbedded(requestPath string, vdir string, assetFn func(name string) ([]byte, error), namesFn func() []string) *Route { fullpath := joinPath(api.relativePath, requestPath) + // if subdomain, + // here we get the full path of the path only, + // because a subdomain can have parties as well + // and we need that path to call the `StripPrefix`. + _, fullpath = splitSubdomainAndPath(fullpath) + requestPath = joinPath(fullpath, WildcardParam("file")) h := api.StaticEmbeddedHandler(vdir, assetFn, namesFn) @@ -625,6 +631,7 @@ func (api *APIBuilder) StaticEmbedded(requestPath string, vdir string, assetFn f h = StripPrefix(fullpath, h) } + // it handles the subdomain(root Party) of this party as well, if any. return api.registerResourceRoute(requestPath, h) } @@ -705,19 +712,24 @@ func (api *APIBuilder) Favicon(favPath string, requestPath ...string) *Route { // // Returns the GET *Route. func (api *APIBuilder) StaticWeb(requestPath string, systemPath string) *Route { - paramName := "file" fullpath := joinPath(api.relativePath, requestPath) + // if subdomain, + // here we get the full path of the path only, + // because a subdomain can have parties as well + // and we need that path to call the `StripPrefix`. + _, fullpath = splitSubdomainAndPath(fullpath) - h := StripPrefix(fullpath, NewStaticHandlerBuilder(systemPath).Listing(false).Build()) + requestPath = joinPath(fullpath, WildcardParam(paramName)) + h := NewStaticHandlerBuilder(systemPath).Listing(false).Build() - handler := func(ctx context.Context) { - h(ctx) + if fullpath != "/" { + h = StripPrefix(fullpath, h) } - requestPath = joinPath(requestPath, WildcardParam(paramName)) - return api.registerResourceRoute(requestPath, handler) + // it handles the subdomain(root Party) of this party as well, if any. + return api.registerResourceRoute(requestPath, h) } // OnErrorCode registers an error http status code