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.
()
| 1156 | // serialized as JSON, is compatible with the |
| 1157 | // CloudEvents spec. |
| 1158 | func (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. |