Browse Source

Adds some documentation about the standard

Manu Mtz-Almeida 10 years ago
parent
commit
1d0f1f9c05
1 changed files with 6 additions and 0 deletions
  1. 6 0
      sse-encoder.go

+ 6 - 0
sse-encoder.go

@@ -8,6 +8,10 @@ import (
 	"strings"
 )
 
+// Server-Sent Events
+// W3C Working Draft 29 October 2009
+// http://www.w3.org/TR/2009/WD-eventsource-20091029/
+
 type Event struct {
 	Event string
 	Id    string
@@ -70,6 +74,8 @@ func typeOfData(data interface{}) reflect.Kind {
 }
 
 func escape(str string) string {
+	// any-char		= %x0000-0009 / %x000B-000C / %x000E-10FFFF
+	// 				; a Unicode character other than U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)
 	str = strings.Replace(str, "\n", "\\n", -1)
 	str = strings.Replace(str, "\r", "\\r", -1)
 	return str