Skip to content

Commit

Permalink
fix import cycle lol
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Oct 5, 2024
1 parent fe43a29 commit 8c2e92a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
11 changes: 8 additions & 3 deletions internal/ezhttp/ezhttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"time"

"github.com/spf13/viper"

"github.com/topi314/gobin/v2/server"
)

const (
Expand All @@ -36,6 +34,13 @@ const (
ContentTypeJSON = "application/json"
)

type ErrorResponse struct {
Message string `json:"message"`
Status int `json:"status"`
Path string `json:"path"`
RequestID string `json:"request_id"`
}

type Reader interface {
io.Reader
Headers() http.Header
Expand Down Expand Up @@ -104,7 +109,7 @@ func ProcessBody(method string, rs *http.Response, body any) error {
}
return nil
}
var errRs server.ErrorResponse
var errRs ErrorResponse
if err := json.NewDecoder(rs.Body).Decode(&errRs); err != nil {
return fmt.Errorf("failed to decode error response: %w", err)
}
Expand Down
7 changes: 0 additions & 7 deletions server/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ type (
ExpiresAt *time.Time
}

ErrorResponse struct {
Message string `json:"message"`
Status int `json:"status"`
Path string `json:"path"`
RequestID string `json:"request_id"`
}

DeleteResponse struct {
Versions int `json:"versions"`
}
Expand Down
2 changes: 1 addition & 1 deletion server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (s *Server) error(w http.ResponseWriter, r *http.Request, err error) {
if status == http.StatusInternalServerError {
slog.ErrorContext(r.Context(), "internal server error", tint.Err(err))
}
s.json(w, r, ErrorResponse{
s.json(w, r, ezhttp.ErrorResponse{
Message: err.Error(),
Status: status,
Path: r.URL.Path,
Expand Down

0 comments on commit 8c2e92a

Please sign in to comment.