Skip to content

Commit

Permalink
proper time format (RFC3339)
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Oct 23, 2024
1 parent a97926a commit 9db255a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ $ go run cmd/system-api/*
$ echo "hello world" > pipe.fifo
$ curl localhost:8082/api/v1/new_event?message=this+is+a+test

# Query events (timestamp in UTC)
$ curl -s localhost:8082/api/v1/events | jq -r '(.[] | [.received_at, .message]) | @tsv'
2024-09-24T10:45:50.774339Z hello world
2024-09-24T10:46:02.01221Z this is a test
# Query events (plain text or JSON is supported)
$ curl -s localhost:8082/api/v1/events?format=text
2024-10-23T11:59:35Z hello world
2024-10-23T11:59:36Z hello world
```
2 changes: 1 addition & 1 deletion cmd/system-api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (s *Server) handleGetEvents(w http.ResponseWriter, r *http.Request) {
// write events as plain text response
w.Header().Set("Content-Type", "text/plain")
for _, event := range s.events {
_, err := w.Write([]byte(event.ReceivedAt.Format("2006-01-02 15:04:05 UTC") + " \t " + event.Message + "\n"))
_, err := w.Write([]byte(event.ReceivedAt.Format(time.RFC3339) + " \t " + event.Message + "\n"))
if err != nil {
s.log.Error("Failed to write event", "err", err)
w.WriteHeader(http.StatusInternalServerError)
Expand Down

0 comments on commit 9db255a

Please sign in to comment.