Documentation ¶
Index ¶
- Constants
- func Encode(w io.Writer, e *Event) (err error)
- func GetLastEventID(c *app.RequestContext) string
- type Client
- func (c *Client) GetBody() []byte
- func (c *Client) GetHeaders() map[string]string
- func (c *Client) GetHertzClient() *client.Client
- func (c *Client) GetLastEventID() []byte
- func (c *Client) GetMethod() string
- func (c *Client) GetURL() string
- func (c *Client) SetBody(body []byte)
- func (c *Client) SetDisconnectCallback(fn ConnCallback)
- func (c *Client) SetEncodingBase64(encodingBase64 bool)
- func (c *Client) SetHeaders(headers map[string]string)
- func (c *Client) SetHertzClient(hertzClient *client.Client)
- func (c *Client) SetMaxBufferSize(size int)
- func (c *Client) SetMethod(method string)
- func (c *Client) SetOnConnectCallback(fn ConnCallback)
- func (c *Client) SetResponseCallback(responseCallback ResponseCallback)
- func (c *Client) SetURL(url string)
- func (c *Client) Subscribe(handler func(msg *Event)) error
- func (c *Client) SubscribeWithContext(ctx context.Context, handler func(msg *Event)) error
- type ConnCallback
- type Event
- type EventStreamReader
- type ResponseCallback
- type Stream
Constants ¶
const ( ContentType = "text/event-stream" LastEventID = "Last-Event-ID" )
Variables ¶
This section is empty.
Functions ¶
func GetLastEventID ¶
func GetLastEventID(c *app.RequestContext) string
GetLastEventID retrieve Last-Event-ID header if present.
Types ¶
type Client ¶ added in v0.0.2
type Client struct {
// contains filtered or unexported fields
}
Client handles an incoming server stream
func (*Client) GetHeaders ¶ added in v0.0.2
GetHeaders get sse client headers
func (*Client) GetHertzClient ¶ added in v0.0.2
GetHertzClient get sse client
func (*Client) GetLastEventID ¶ added in v0.0.2
GetLastEventID get sse client lastEventID
func (*Client) SetDisconnectCallback ¶ added in v0.0.2
func (c *Client) SetDisconnectCallback(fn ConnCallback)
SetDisconnectCallback specifies the function to run when the connection disconnects
func (*Client) SetEncodingBase64 ¶ added in v0.0.2
SetEncodingBase64 set sse client whether use the base64
func (*Client) SetHeaders ¶ added in v0.0.2
SetHeaders set sse client headers
func (*Client) SetHertzClient ¶ added in v0.0.2
SetHertzClient set sse client
func (*Client) SetMaxBufferSize ¶ added in v0.0.2
SetMaxBufferSize set sse client MaxBufferSize
func (*Client) SetOnConnectCallback ¶ added in v0.0.2
func (c *Client) SetOnConnectCallback(fn ConnCallback)
SetOnConnectCallback specifies the function to run when the connection is successful
func (*Client) SetResponseCallback ¶ added in v0.0.2
func (c *Client) SetResponseCallback(responseCallback ResponseCallback)
SetResponseCallback set sse client responseCallback
type ConnCallback ¶ added in v0.0.2
ConnCallback defines a function to be called on a particular connection event
type EventStreamReader ¶ added in v0.0.2
type EventStreamReader struct {
// contains filtered or unexported fields
}
EventStreamReader scans an io.Reader looking for EventStream messages.
func NewEventStreamReader ¶ added in v0.0.2
func NewEventStreamReader(eventStream io.Reader, maxBufferSize int) *EventStreamReader
NewEventStreamReader creates an instance of EventStreamReader.
type ResponseCallback ¶ added in v0.0.2
type ResponseCallback func(ctx context.Context, req *protocol.Request, resp *protocol.Response) error
ResponseCallback validates a response
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
client/quickstart
* Copyright 2024 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
* Copyright 2024 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |
server/quickstart
* Copyright 2024 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
* Copyright 2024 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |