summaryrefslogtreecommitdiff
path: root/vendor/github.com/gin-contrib/sse
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gin-contrib/sse')
-rw-r--r--vendor/github.com/gin-contrib/sse/.golangci.yml3
-rw-r--r--vendor/github.com/gin-contrib/sse/.goreleaser.yaml29
-rw-r--r--vendor/github.com/gin-contrib/sse/.travis.yml26
-rw-r--r--vendor/github.com/gin-contrib/sse/README.md42
-rw-r--r--vendor/github.com/gin-contrib/sse/sse-encoder.go10
5 files changed, 63 insertions, 47 deletions
diff --git a/vendor/github.com/gin-contrib/sse/.golangci.yml b/vendor/github.com/gin-contrib/sse/.golangci.yml
new file mode 100644
index 000000000..4c44c5fae
--- /dev/null
+++ b/vendor/github.com/gin-contrib/sse/.golangci.yml
@@ -0,0 +1,3 @@
+linters:
+ disable:
+ - errcheck
diff --git a/vendor/github.com/gin-contrib/sse/.goreleaser.yaml b/vendor/github.com/gin-contrib/sse/.goreleaser.yaml
new file mode 100644
index 000000000..4c910add4
--- /dev/null
+++ b/vendor/github.com/gin-contrib/sse/.goreleaser.yaml
@@ -0,0 +1,29 @@
+builds:
+ - # If true, skip the build.
+ # Useful for library projects.
+ # Default is false
+ skip: true
+
+changelog:
+ use: github
+ groups:
+ - title: Features
+ regexp: "^.*feat[(\\w)]*:+.*$"
+ order: 0
+ - title: "Bug fixes"
+ regexp: "^.*fix[(\\w)]*:+.*$"
+ order: 1
+ - title: "Enhancements"
+ regexp: "^.*chore[(\\w)]*:+.*$"
+ order: 2
+ - title: "Refactor"
+ regexp: "^.*refactor[(\\w)]*:+.*$"
+ order: 3
+ - title: "Build process updates"
+ regexp: ^.*?(build|ci)(\(.+\))??!?:.+$
+ order: 4
+ - title: "Documentation updates"
+ regexp: ^.*?docs?(\(.+\))??!?:.+$
+ order: 4
+ - title: Others
+ order: 999
diff --git a/vendor/github.com/gin-contrib/sse/.travis.yml b/vendor/github.com/gin-contrib/sse/.travis.yml
deleted file mode 100644
index d0e8fcf99..000000000
--- a/vendor/github.com/gin-contrib/sse/.travis.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-language: go
-sudo: false
-go:
- - 1.8.x
- - 1.9.x
- - 1.10.x
- - 1.11.x
- - 1.12.x
- - master
-
-git:
- depth: 10
-
-matrix:
- fast_finish: true
- include:
- - go: 1.11.x
- env: GO111MODULE=on
- - go: 1.12.x
- env: GO111MODULE=on
-
-script:
- - go test -v -covermode=count -coverprofile=coverage.out
-
-after_success:
- - bash <(curl -s https://codecov.io/bash)
diff --git a/vendor/github.com/gin-contrib/sse/README.md b/vendor/github.com/gin-contrib/sse/README.md
index c9c49cf94..cfe2c820b 100644
--- a/vendor/github.com/gin-contrib/sse/README.md
+++ b/vendor/github.com/gin-contrib/sse/README.md
@@ -1,7 +1,7 @@
# Server-Sent Events
-[![GoDoc](https://godoc.org/github.com/gin-contrib/sse?status.svg)](https://godoc.org/github.com/gin-contrib/sse)
-[![Build Status](https://travis-ci.org/gin-contrib/sse.svg)](https://travis-ci.org/gin-contrib/sse)
+[![Go Reference](https://pkg.go.dev/badge/github.com/gin-contrib/sse.svg)](https://pkg.go.dev/github.com/gin-contrib/sse)
+[![Run Tests](https://github.com/gin-contrib/sse/actions/workflows/go.yml/badge.svg)](https://github.com/gin-contrib/sse/actions/workflows/go.yml)
[![codecov](https://codecov.io/gh/gin-contrib/sse/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-contrib/sse)
[![Go Report Card](https://goreportcard.com/badge/github.com/gin-contrib/sse)](https://goreportcard.com/report/github.com/gin-contrib/sse)
@@ -16,32 +16,33 @@ Server-sent events (SSE) is a technology where a browser receives automatic upda
import "github.com/gin-contrib/sse"
func httpHandler(w http.ResponseWriter, req *http.Request) {
- // data can be a primitive like a string, an integer or a float
- sse.Encode(w, sse.Event{
- Event: "message",
- Data: "some data\nmore data",
- })
+ // data can be a primitive like a string, an integer or a float
+ sse.Encode(w, sse.Event{
+ Event: "message",
+ Data: "some data\nmore data",
+ })
- // also a complex type, like a map, a struct or a slice
- sse.Encode(w, sse.Event{
- Id: "124",
- Event: "message",
- Data: map[string]interface{}{
- "user": "manu",
- "date": time.Now().Unix(),
- "content": "hi!",
- },
- })
+ // also a complex type, like a map, a struct or a slice
+ sse.Encode(w, sse.Event{
+ Id: "124",
+ Event: "message",
+ Data: map[string]interface{}{
+ "user": "manu",
+ "date": time.Now().Unix(),
+ "content": "hi!",
+ },
+ })
}
```
-```
+
+```sh
event: message
data: some data\\nmore data
id: 124
event: message
data: {"content":"hi!","date":1431540810,"user":"manu"}
-
+
```
## Content-Type
@@ -49,7 +50,8 @@ data: {"content":"hi!","date":1431540810,"user":"manu"}
```go
fmt.Println(sse.ContentType)
```
-```
+
+```sh
text/event-stream
```
diff --git a/vendor/github.com/gin-contrib/sse/sse-encoder.go b/vendor/github.com/gin-contrib/sse/sse-encoder.go
index f9c808750..0d26c82f0 100644
--- a/vendor/github.com/gin-contrib/sse/sse-encoder.go
+++ b/vendor/github.com/gin-contrib/sse/sse-encoder.go
@@ -18,7 +18,7 @@ import (
// W3C Working Draft 29 October 2009
// http://www.w3.org/TR/2009/WD-eventsource-20091029/
-const ContentType = "text/event-stream"
+const ContentType = "text/event-stream;charset=utf-8"
var contentType = []string{ContentType}
var noCache = []string{"no-cache"}
@@ -72,6 +72,14 @@ func writeRetry(w stringWriter, retry uint) {
func writeData(w stringWriter, data interface{}) error {
w.WriteString("data:")
+
+ bData, ok := data.([]byte)
+ if ok {
+ dataReplacer.WriteString(w, string(bData))
+ w.WriteString("\n\n")
+ return nil
+ }
+
switch kindOfData(data) {
case reflect.Struct, reflect.Slice, reflect.Map:
err := json.NewEncoder(w).Encode(data)