Draft: feat login

This commit is contained in:
2025-09-05 03:59:25 +08:00
parent 6d7074198f
commit 0e3e1a5f23
38 changed files with 1546 additions and 90 deletions

View File

@@ -15,8 +15,6 @@ type HTTPError struct {
StatusCode int `json:"code"`
Message string `json:"message"`
OriginError error `json:"-"`
TraceID string `json:"traceId"`
}
func (e HTTPError) Error() string {
@@ -31,7 +29,9 @@ func NewHTTPError(err error) HTTPError {
}
}
func ErrorHandler(next bunrouter.HandlerFunc) bunrouter.HandlerFunc {
func (self *Handlers) ErrorHandler(
next bunrouter.HandlerFunc,
) bunrouter.HandlerFunc {
return func(w http.ResponseWriter, req bunrouter.Request) error {
err := next(w, req)
ctx := req.Context()
@@ -53,7 +53,6 @@ func ErrorHandler(next bunrouter.HandlerFunc) bunrouter.HandlerFunc {
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
span := trace.SpanFromContext(ctx)
httpErr.TraceID = span.SpanContext().TraceID().String()
span.SetAttributes(
attribute.Int("http.response.status_code", httpErr.StatusCode),
)