Skip to content

deftstar/gosupport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gosupport

Turn server-side errors in a Go app into Support tickets that carry the real server detail — no Sentry or other error tracker required (Support is the store).

Report-gated: on a 5xx the middleware buffers the error detail locally (short TTL), keyed by a correlation id it stamps on the response. The detail is pushed to Support only when a user reports it (via the Flush handler you mount), so Support never stores errors nobody reported, and the detail stays server-side until then.

Install

go get github.com/deftstar/gosupport

Use

r := gosupport.New(gosupport.Config{
    IngestURL: "https://support-api.deftstar.dev/api/ingest/errors",
    SecretKey: os.Getenv("SUPPORT_SECRET_KEY"), // project secret (sk_…); never sent to the browser
})

// Mount the flush endpoint behind your own auth, and wrap your router:
mux.Handle("/support/errors/flush", requireAuth(http.HandlerFunc(r.Flush)))
http.ListenAndServe(":8080", r.Middleware(mux))

On a 5xx (or panic) the correlation id is set on the X-Request-Id response header and the detail is buffered. The browser reads that header; when the user reports, the frontend POSTs {"requestId": "…"} to your flush route → that one error is pushed to Support and the ticket links to it.

Options

field default notes
IngestURL, SecretKey required
Source "local" error-source label
HeaderName "X-Request-Id" correlation-id header; reuses an inbound one
TTL 30m how long a 5xx is buffered awaiting a report
Store in-process TTL map provide a shared (Redis) store if you run multiple instances
Sample status >= 500 what to buffer
Client, NewID, OnError sensible HTTP client / id generator / failure observer

Get the id in a handler with gosupport.RequestID(r.Context()); buffer explicitly with r.Buffer(id, msg, detail); flush programmatically with r.FlushID(id).

Release

git tag v0.1.0 && git push origin v0.1.0

Public module — go get github.com/deftstar/gosupport@v0.1.0 works immediately via the Go proxy; no registry account needed.

About

Report-gated Go middleware that turns 5xx errors into Support tickets carrying the real server detail. No Sentry required.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages