caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
55.45k stars 3.91k forks source link

`caddyevents.CaddyEvent` does not provide accessors to event metadata #6377

Closed ankon closed 3 weeks ago

ankon commented 3 weeks ago

https://github.com/caddyserver/caddy/blob/5db2f81695c27016c154743929fe727cbfa0c8f9/modules/caddyevents/app.go#L352-354

The timestamp, id, and name/type of the event aren't available to any consumers, which makes actually using these hard. One can use the CloudEvent() function to get these values, but that also requires a potentially costly serialization of the complete event data to JSON.

Can we add suitable getters for timestamp, id, name/type here?

francislavoie commented 3 weeks ago

That info can be pulled out of the replacer, see https://github.com/caddyserver/caddy/blob/5db2f81695c27016c154743929fe727cbfa0c8f9/modules/caddyevents/app.go#L245

mholt commented 3 weeks ago

Oh, gotcha. I didn't know people would want these. Lemme see about exporting them or adding getters.