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.yml50
-rw-r--r--vendor/github.com/gin-contrib/sse/.goreleaser.yaml29
-rw-r--r--vendor/github.com/gin-contrib/sse/LICENSE21
-rw-r--r--vendor/github.com/gin-contrib/sse/README.md60
-rw-r--r--vendor/github.com/gin-contrib/sse/sse-decoder.go117
-rw-r--r--vendor/github.com/gin-contrib/sse/sse-encoder.go120
-rw-r--r--vendor/github.com/gin-contrib/sse/writer.go24
7 files changed, 0 insertions, 421 deletions
diff --git a/vendor/github.com/gin-contrib/sse/.golangci.yml b/vendor/github.com/gin-contrib/sse/.golangci.yml
deleted file mode 100644
index 47094ac61..000000000
--- a/vendor/github.com/gin-contrib/sse/.golangci.yml
+++ /dev/null
@@ -1,50 +0,0 @@
-version: "2"
-linters:
- default: none
- enable:
- - bodyclose
- - dogsled
- - dupl
- - errcheck
- - exhaustive
- - gochecknoinits
- - goconst
- - gocritic
- - gocyclo
- - goprintffuncname
- - gosec
- - govet
- - ineffassign
- - lll
- - misspell
- - nakedret
- - noctx
- - nolintlint
- - rowserrcheck
- - staticcheck
- - unconvert
- - unparam
- - unused
- - whitespace
- exclusions:
- generated: lax
- presets:
- - comments
- - common-false-positives
- - legacy
- - std-error-handling
- paths:
- - third_party$
- - builtin$
- - examples$
-formatters:
- enable:
- - gofmt
- - gofumpt
- - goimports
- exclusions:
- generated: lax
- paths:
- - third_party$
- - builtin$
- - examples$
diff --git a/vendor/github.com/gin-contrib/sse/.goreleaser.yaml b/vendor/github.com/gin-contrib/sse/.goreleaser.yaml
deleted file mode 100644
index 4c910add4..000000000
--- a/vendor/github.com/gin-contrib/sse/.goreleaser.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-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/LICENSE b/vendor/github.com/gin-contrib/sse/LICENSE
deleted file mode 100644
index 1ff7f3706..000000000
--- a/vendor/github.com/gin-contrib/sse/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2014 Manuel Martínez-Almeida
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/vendor/github.com/gin-contrib/sse/README.md b/vendor/github.com/gin-contrib/sse/README.md
deleted file mode 100644
index cfe2c820b..000000000
--- a/vendor/github.com/gin-contrib/sse/README.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# Server-Sent Events
-
-[![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)
-
-Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is [standardized as part of HTML5[1] by the W3C](http://www.w3.org/TR/2009/WD-eventsource-20091029/).
-
-- [Read this great SSE introduction by the HTML5Rocks guys](http://www.html5rocks.com/en/tutorials/eventsource/basics/)
-- [Browser support](http://caniuse.com/#feat=eventsource)
-
-## Sample code
-
-```go
-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",
- })
-
- // 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
-
-```go
-fmt.Println(sse.ContentType)
-```
-
-```sh
-text/event-stream
-```
-
-## Decoding support
-
-There is a client-side implementation of SSE coming soon.
diff --git a/vendor/github.com/gin-contrib/sse/sse-decoder.go b/vendor/github.com/gin-contrib/sse/sse-decoder.go
deleted file mode 100644
index da2c2d4b6..000000000
--- a/vendor/github.com/gin-contrib/sse/sse-decoder.go
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
-// Use of this source code is governed by a MIT style
-// license that can be found in the LICENSE file.
-
-package sse
-
-import (
- "bytes"
- "io"
-)
-
-type decoder struct {
- events []Event
-}
-
-func Decode(r io.Reader) ([]Event, error) {
- var dec decoder
- return dec.decode(r)
-}
-
-func (d *decoder) dispatchEvent(event Event, data string) {
- dataLength := len(data)
- if dataLength > 0 {
- // If the data buffer's last character is a U+000A LINE FEED (LF) character,
- // then remove the last character from the data buffer.
- data = data[:dataLength-1]
- dataLength--
- }
- if dataLength == 0 && event.Event == "" {
- return
- }
- if event.Event == "" {
- event.Event = "message"
- }
- event.Data = data
- d.events = append(d.events, event)
-}
-
-func (d *decoder) decode(r io.Reader) ([]Event, error) {
- buf, err := io.ReadAll(r)
- if err != nil {
- return nil, err
- }
-
- var currentEvent Event
- dataBuffer := new(bytes.Buffer)
- // TODO (and unit tests)
- // Lines must be separated by either a U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair,
- // a single U+000A LINE FEED (LF) character,
- // or a single U+000D CARRIAGE RETURN (CR) character.
- lines := bytes.Split(buf, []byte{'\n'})
- for _, line := range lines {
- if len(line) == 0 {
- // If the line is empty (a blank line). Dispatch the event.
- d.dispatchEvent(currentEvent, dataBuffer.String())
-
- // reset current event and data buffer
- currentEvent = Event{}
- dataBuffer.Reset()
- continue
- }
- if line[0] == byte(':') {
- // If the line starts with a U+003A COLON character (:), ignore the line.
- continue
- }
-
- var field, value []byte
- colonIndex := bytes.IndexRune(line, ':')
- if colonIndex != -1 {
- // If the line contains a U+003A COLON character character (:)
- // Collect the characters on the line before the first U+003A COLON character (:),
- // and let field be that string.
- field = line[:colonIndex]
- // Collect the characters on the line after the first U+003A COLON character (:),
- // and let value be that string.
- value = line[colonIndex+1:]
- // If value starts with a single U+0020 SPACE character, remove it from value.
- if len(value) > 0 && value[0] == ' ' {
- value = value[1:]
- }
- } else {
- // Otherwise, the string is not empty but does not contain a U+003A COLON character character (:)
- // Use the whole line as the field name, and the empty string as the field value.
- field = line
- value = []byte{}
- }
- // The steps to process the field given a field name and a field value depend on the field name,
- // as given in the following list. Field names must be compared literally,
- // with no case folding performed.
- switch string(field) {
- case "event":
- // Set the event name buffer to field value.
- currentEvent.Event = string(value)
- case "id":
- // Set the event stream's last event ID to the field value.
- currentEvent.Id = string(value)
- case "retry":
- // If the field value consists of only characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
- // then interpret the field value as an integer in base ten, and set the event stream's
- // reconnection time to that integer.
- // Otherwise, ignore the field.
- currentEvent.Id = string(value)
- case "data":
- // Append the field value to the data buffer,
- dataBuffer.Write(value)
- // then append a single U+000A LINE FEED (LF) character to the data buffer.
- dataBuffer.WriteString("\n")
- default:
- // Otherwise. The field is ignored.
- continue
- }
- }
- // Once the end of the file is reached, the user agent must dispatch the event one final time.
- d.dispatchEvent(currentEvent, dataBuffer.String())
-
- return d.events, nil
-}
diff --git a/vendor/github.com/gin-contrib/sse/sse-encoder.go b/vendor/github.com/gin-contrib/sse/sse-encoder.go
deleted file mode 100644
index 9ebb49f41..000000000
--- a/vendor/github.com/gin-contrib/sse/sse-encoder.go
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
-// Use of this source code is governed by a MIT style
-// license that can be found in the LICENSE file.
-
-package sse
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "net/http"
- "reflect"
- "strconv"
- "strings"
-)
-
-// Server-Sent Events
-// W3C Working Draft 29 October 2009
-// http://www.w3.org/TR/2009/WD-eventsource-20091029/
-
-const ContentType = "text/event-stream;charset=utf-8"
-
-var (
- contentType = []string{ContentType}
- noCache = []string{"no-cache"}
-)
-
-var fieldReplacer = strings.NewReplacer(
- "\n", "\\n",
- "\r", "\\r")
-
-var dataReplacer = strings.NewReplacer(
- "\n", "\ndata:",
- "\r", "\\r")
-
-type Event struct {
- Event string
- Id string
- Retry uint
- Data interface{}
-}
-
-func Encode(writer io.Writer, event Event) error {
- w := checkWriter(writer)
- writeId(w, event.Id)
- writeEvent(w, event.Event)
- writeRetry(w, event.Retry)
- return writeData(w, event.Data)
-}
-
-func writeId(w stringWriter, id string) {
- if len(id) > 0 {
- _, _ = w.WriteString("id:")
- _, _ = fieldReplacer.WriteString(w, id)
- _, _ = w.WriteString("\n")
- }
-}
-
-func writeEvent(w stringWriter, event string) {
- if len(event) > 0 {
- _, _ = w.WriteString("event:")
- _, _ = fieldReplacer.WriteString(w, event)
- _, _ = w.WriteString("\n")
- }
-}
-
-func writeRetry(w stringWriter, retry uint) {
- if retry > 0 {
- _, _ = w.WriteString("retry:")
- _, _ = w.WriteString(strconv.FormatUint(uint64(retry), 10))
- _, _ = w.WriteString("\n")
- }
-}
-
-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) { //nolint:exhaustive
- case reflect.Struct, reflect.Slice, reflect.Map:
- err := json.NewEncoder(w).Encode(data)
- if err != nil {
- return err
- }
- _, _ = w.WriteString("\n")
- default:
- _, _ = dataReplacer.WriteString(w, fmt.Sprint(data))
- _, _ = w.WriteString("\n\n")
- }
- return nil
-}
-
-func (r Event) Render(w http.ResponseWriter) error {
- r.WriteContentType(w)
- return Encode(w, r)
-}
-
-func (r Event) WriteContentType(w http.ResponseWriter) {
- header := w.Header()
- header["Content-Type"] = contentType
-
- if _, exist := header["Cache-Control"]; !exist {
- header["Cache-Control"] = noCache
- }
-}
-
-func kindOfData(data interface{}) reflect.Kind {
- value := reflect.ValueOf(data)
- valueType := value.Kind()
- if valueType == reflect.Ptr {
- valueType = value.Elem().Kind()
- }
- return valueType
-}
diff --git a/vendor/github.com/gin-contrib/sse/writer.go b/vendor/github.com/gin-contrib/sse/writer.go
deleted file mode 100644
index 724d9d07d..000000000
--- a/vendor/github.com/gin-contrib/sse/writer.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package sse
-
-import "io"
-
-type stringWriter interface {
- io.Writer
- WriteString(string) (int, error)
-}
-
-type stringWrapper struct {
- io.Writer
-}
-
-func (w stringWrapper) WriteString(str string) (int, error) {
- return w.Write([]byte(str))
-}
-
-func checkWriter(writer io.Writer) stringWriter {
- if w, ok := writer.(stringWriter); ok {
- return w
- } else {
- return stringWrapper{writer}
- }
-}