MCPcopy
hub / github.com/caddyserver/caddy / CloudEvent

Method CloudEvent

caddy.go:1158–1175  ·  view source on GitHub ↗

Returns the module that originated the event. May be nil, usually if caddy core emits the event. CloudEvent exports event e as a structure that, when serialized as JSON, is compatible with the CloudEvents spec.

()

Source from the content-addressed store, hash-verified

1156// serialized as JSON, is compatible with the
1157// CloudEvents spec.
1158func (e Event) CloudEvent() CloudEvent {
1159 dataJSON, _ := json.Marshal(e.Data)
1160 var source string
1161 if e.Origin() == nil {
1162 source = "caddy"
1163 } else {
1164 source = string(e.Origin().CaddyModule().ID)
1165 }
1166 return CloudEvent{
1167 ID: e.id.String(),
1168 Source: source,
1169 SpecVersion: "1.0",
1170 Type: e.name,
1171 Time: e.ts,
1172 DataContentType: "application/json",
1173 Data: dataJSON,
1174 }
1175}
1176
1177// CloudEvent is a JSON-serializable structure that
1178// is compatible with the CloudEvents specification.

Callers 1

Calls 3

OriginMethod · 0.95
CaddyModuleMethod · 0.65
StringMethod · 0.45

Tested by 1