From 4818d184b16a0ddd508216537bd38e999a81460d Mon Sep 17 00:00:00 2001 From: kataras Date: Fri, 24 Nov 2017 20:13:10 +0200 Subject: [PATCH 1/4] remove codesponsor as http://mailchi.mp/f9b57b5ea377/code-sponsor-is-shutting-down-on-december-8 Former-commit-id: 94c7c2e2770b02e1c93e2e830606dac204d5b0f6 --- README.md | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/README.md b/README.md index 9a4bbcf5..bb656678 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ # [![Logo created by @santoshanand](logo_white_35_24.png)](https://iris-go.com) Iris -[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=flat-square)](https://travis-ci.org/kataras/iris)[![Backers on Open Collective](https://opencollective.com/iris/backers/badge.svg?style=flat-square)](#backers)[![Sponsors on Open Collective](https://opencollective.com/iris/sponsors/badge.svg?style=flat-square)](#sponsors)[![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris)[![github closed issues](https://img.shields.io/github/issues-closed-raw/kataras/iris.svg?style=flat-square)](https://github.com/kataras/iris/issues?q=is%3Aissue+is%3Aclosed)[![release](https://img.shields.io/github/release/kataras/iris.svg?style=flat-square)](https://github.com/kataras/iris/releases)[![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/tree/master/_examples)[![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris)[![CLA assistant](https://cla-assistant.io/readme/badge/kataras/iris?style=flat-square)](https://cla-assistant.io/kataras/iris) - - - Sponsor - +[![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)[![github closed issues](https://img.shields.io/github/issues-closed-raw/kataras/iris.svg?style=flat-square)](https://github.com/kataras/iris/issues?q=is%3Aissue+is%3Aclosed)[![release](https://img.shields.io/github/release/kataras/iris.svg?style=flat-square)](https://github.com/kataras/iris/releases)[![view examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](https://github.com/kataras/iris/tree/master/_examples)[![chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris)[![CLA assistant](https://cla-assistant.io/readme/badge/kataras/iris?style=flat-square)](https://cla-assistant.io/kataras/iris) Iris is a fast, simple and efficient web framework for Go. @@ -1051,17 +1047,6 @@ The form contains some questions that you may need to answer in order to learn m https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link -## Contributors - -This project exists thanks to all the people who contribute. [Contribute](CONTRIBUTING.md). - - -## Backers - -Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/iris#backer) - - - ## Sponsors Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor](https://opencollective.com/iris#sponsor) From 80b86136f40c248ae2fb958b7ba38c0a33ed39bc Mon Sep 17 00:00:00 2001 From: Gerson Alexander Pardo Gamez Date: Fri, 1 Dec 2017 17:48:37 -0500 Subject: [PATCH 2/4] Websocket: added OnPing to Connection see issue #825 Former-commit-id: c7c97d40e352f4e550ea96eb482e71c3c50c8c09 --- websocket/connection.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/websocket/connection.go b/websocket/connection.go index 2e6f46cf..9f18dcbd 100644 --- a/websocket/connection.go +++ b/websocket/connection.go @@ -131,6 +131,8 @@ type ( // MessageFunc is the second argument to the Emitter's Emit functions. // A callback which should receives one parameter of type string, int, bool or any valid JSON/Go struct MessageFunc interface{} + // PingFunc is the callback which fires each ping + PingFunc func() // Connection is the front-end API that you will use to communicate with the client side Connection interface { // Emitter implements EmitMessage & Emit @@ -154,6 +156,8 @@ type ( OnDisconnect(DisconnectFunc) // OnError registers a callback which fires when this connection occurs an error OnError(ErrorFunc) + // OnPing registers a callback which fires on each ping + OnPing(PingFunc) // FireStatusCode can be used to send a custom error message to the connection // // It does nothing more than firing the OnError listeners. It doesn't sends anything to the client. @@ -200,6 +204,7 @@ type ( onDisconnectListeners []DisconnectFunc onRoomLeaveListeners []LeaveRoomFunc onErrorListeners []ErrorFunc + onPingListeners []PingFunc onNativeMessageListeners []NativeMessageFunc onEventListeners map[string][]MessageFunc // these were maden for performance only @@ -305,6 +310,8 @@ func (c *connection) startPinger() { // verifies if already disconected break } + //fire all OnPing methods + c.fireOnPing() // try to ping the client, if failed then it disconnects err := c.write(websocket.PingMessage, []byte{}) if err != nil { @@ -430,6 +437,10 @@ func (c *connection) OnError(cb ErrorFunc) { c.onErrorListeners = append(c.onErrorListeners, cb) } +func (c *connection) OnPing(cb PingFunc) { + c.onPingListeners = append(c.onPingListeners, cb) +} + func (c *connection) FireOnError(errorMessage string) { for _, cb := range c.onErrorListeners { cb(errorMessage) @@ -492,6 +503,13 @@ func (c *connection) fireOnLeave(roomName string) { } } +func (c *connection) fireOnPing() { + // fire the onPingListeners + for i := range c.onPingListeners { + c.onPingListeners[i]() + } +} + func (c *connection) Disconnect() error { return c.server.Disconnect(c.ID()) } From 9197fd73498c2537c4254e2ed7be4e138138a763 Mon Sep 17 00:00:00 2001 From: honux Date: Sat, 2 Dec 2017 17:45:43 -0200 Subject: [PATCH 3/4] Fixed a bug on router/path - Stored the args length on a variable instead of three consecutive calls to the len method on "toStringSlice" function; - Improved readability on "toStringSlice" function; - Fixed a bug on "URL", which all routes without parameters would not return the full uri (just the path); Former-commit-id: 3ddd8869087aa9046bdb874f98985b76daaa249e --- core/router/path.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/core/router/path.go b/core/router/path.go index 732e944c..914f75e7 100644 --- a/core/router/path.go +++ b/core/router/path.go @@ -209,12 +209,13 @@ func (ps *RoutePathReverser) Path(routeName string, paramValues ...interface{}) return r.ResolvePath(toStringSlice(paramValues)...) } -func toStringSlice(args []interface{}) []string { - var argsString []string - if len(args) > 0 { - argsString = make([]string, len(args), len(args)) +func toStringSlice(args []interface{}) (argsString []string) { + argsSize := len(args) + if argsSize <= 0 { + return } + argsString = make([]string, argsSize, argsSize) for i, v := range args { if s, ok := v.(string); ok { argsString[i] = s @@ -229,7 +230,7 @@ func toStringSlice(args []interface{}) []string { } } } - return argsString + return } // Remove the URL for now, it complicates things for the whole framework without a specific benefits, @@ -246,21 +247,16 @@ func (ps *RoutePathReverser) URL(routeName string, paramValues ...interface{}) ( return } - if len(paramValues) == 0 { - return r.Path - } - - args := toStringSlice(paramValues) - host := ps.vhost scheme := ps.vscheme + args := toStringSlice(paramValues) + // if it's dynamic subdomain then the first argument is the subdomain part // for this part we are responsible not the custom routers - if r.Subdomain == SubdomainWildcardIndicator { + if len(args) > 0 && r.Subdomain == SubdomainWildcardIndicator { subdomain := args[0] host = subdomain + "." + host args = args[1:] // remove the subdomain part for the arguments, - } if parsedPath := r.ResolvePath(args...); parsedPath != "" { From 412c513e5f582ad30ea36dde01b43afa05015dfb Mon Sep 17 00:00:00 2001 From: honux Date: Sun, 3 Dec 2017 23:21:11 -0200 Subject: [PATCH 4/4] Fix subfolder templating issue Fixed issue https://github.com/kataras/iris/issues/830 Former-commit-id: 1be9b65fd51322c927ebfdcb835ef1df5b018a5a --- view/amber.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/amber.go b/view/amber.go index 32547830..84d6d97f 100644 --- a/view/amber.go +++ b/view/amber.go @@ -213,7 +213,7 @@ func (s *AmberEngine) ExecuteWriter(w io.Writer, filename string, layout string, } if tmpl := s.fromCache(filename); tmpl != nil { - return tmpl.ExecuteTemplate(w, filename, bindingData) + return tmpl.Execute(w, bindingData) } return fmt.Errorf("Template with name %s doesn't exists in the dir", filename)