forked from alexandrevicenzi/go-sse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
29 lines (26 loc) · 924 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package sse
import (
"log"
"net/http"
)
// Options holds server configurations.
type Options struct {
// RetryInterval change EventSource default retry interval (milliseconds).
RetryInterval int
// Headers allow to set custom headers (useful for CORS support).
Headers map[string]string
// ChannelNameFunc allow to create custom channel names.
// Default channel name is the request path.
ChannelNameFunc func(*http.Request) string
// ClientNameFunc allows to create custom name for client
ClientNameFunc func(r *http.Request) string
// ClientConnectedFunc allows to receive callback upon client connect
ClientConnectedFunc func(c *Client)
// ClientDisconnectedFunc allows to receive callback upon client disconnect
ClientDisconnectedFunc func(c *Client)
// All usage logs end up in Logger
Logger *log.Logger
}
func (opt *Options) hasHeaders() bool {
return opt.Headers != nil && len(opt.Headers) > 0
}