MCPcopy
hub / github.com/cloudflare/cloudflared / IntoServerEvent

Function IntoServerEvent

management/events.go:223–233  ·  view source on GitHub ↗

IntoServerEvent unmarshals the provided ServerEvent into the proper type.

(e *ServerEvent, eventType ServerEventType)

Source from the content-addressed store, hash-verified

221
222// IntoServerEvent unmarshals the provided ServerEvent into the proper type.
223func IntoServerEvent[T EventLog](e *ServerEvent, eventType ServerEventType) (*T, bool) {
224 if e.Type != eventType {
225 return nil, false
226 }
227 event := new(T)
228 err := json.Unmarshal(e.event, event)
229 if err != nil {
230 return nil, false
231 }
232 return event, true
233}
234
235// ReadEvent will read a message from the websocket connection and parse it into a valid ServerEvent.
236func ReadServerEvent(c *websocket.Conn, ctx context.Context) (*ServerEvent, error) {

Callers 3

RunFunction · 0.92
TestIntoServerEvent_LogsFunction · 0.85

Calls 1

UnmarshalMethod · 0.45

Tested by 2

TestIntoServerEvent_LogsFunction · 0.68