Skip to content

Commit 8c2e92a

Browse files
committed
fix import cycle lol
1 parent fe43a29 commit 8c2e92a

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

internal/ezhttp/ezhttp.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"time"
99

1010
"github.com/spf13/viper"
11-
12-
"github.com/topi314/gobin/v2/server"
1311
)
1412

1513
const (
@@ -36,6 +34,13 @@ const (
3634
ContentTypeJSON = "application/json"
3735
)
3836

37+
type ErrorResponse struct {
38+
Message string `json:"message"`
39+
Status int `json:"status"`
40+
Path string `json:"path"`
41+
RequestID string `json:"request_id"`
42+
}
43+
3944
type Reader interface {
4045
io.Reader
4146
Headers() http.Header
@@ -104,7 +109,7 @@ func ProcessBody(method string, rs *http.Response, body any) error {
104109
}
105110
return nil
106111
}
107-
var errRs server.ErrorResponse
112+
var errRs ErrorResponse
108113
if err := json.NewDecoder(rs.Body).Decode(&errRs); err != nil {
109114
return fmt.Errorf("failed to decode error response: %w", err)
110115
}

server/document.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ type (
7070
ExpiresAt *time.Time
7171
}
7272

73-
ErrorResponse struct {
74-
Message string `json:"message"`
75-
Status int `json:"status"`
76-
Path string `json:"path"`
77-
RequestID string `json:"request_id"`
78-
}
79-
8073
DeleteResponse struct {
8174
Versions int `json:"versions"`
8275
}

server/routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (s *Server) error(w http.ResponseWriter, r *http.Request, err error) {
205205
if status == http.StatusInternalServerError {
206206
slog.ErrorContext(r.Context(), "internal server error", tint.Err(err))
207207
}
208-
s.json(w, r, ErrorResponse{
208+
s.json(w, r, ezhttp.ErrorResponse{
209209
Message: err.Error(),
210210
Status: status,
211211
Path: r.URL.Path,

0 commit comments

Comments
 (0)