Skip to content

Commit bfec115

Browse files
committed
refactor: remove unused Event response utility methods and related tests
1 parent 0c576fc commit bfec115

2 files changed

Lines changed: 0 additions & 53 deletions

File tree

event.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ func (e *Event) Response() http.ResponseWriter {
6666
return e.response
6767
}
6868

69-
func (e *Event) woResp() *Response {
70-
return MustUnwrapResponse(e.response)
71-
}
72-
7369
func (e *Event) Context() context.Context {
7470
return e.request.Context()
7571
}
@@ -98,24 +94,6 @@ func (e *Event) StartTime() time.Time {
9894
return e.start
9995
}
10096

101-
// Flush flushes buffered data to the current response.
102-
//
103-
// Returns [http.ErrNotSupported] if e.response doesn't implement the [http.Flusher] interface
104-
// (all router package handlers receives a ResponseWriter that implements it unless explicitly replaced with a custom one).
105-
func (e *Event) Flush() error {
106-
return e.woResp().FlushError()
107-
}
108-
109-
// Written reports whether the current response has already been written.
110-
func (e *Event) Written() bool {
111-
return e.woResp().Written
112-
}
113-
114-
// Status reports the status code of the current response.
115-
func (e *Event) Status() int {
116-
return e.woResp().Status
117-
}
118-
11997
func (e *Event) UserAgent() string {
12098
return e.request.UserAgent()
12199
}

event_test.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -219,37 +219,6 @@ func TestEvent_SetDebug(t *testing.T) {
219219
}
220220
}
221221

222-
func TestEvent_Flush(t *testing.T) {
223-
rec := httptest.NewRecorder()
224-
resp := NewResponse(rec)
225-
226-
event, _, _ := newTestEventForEventTest()
227-
event.SetResponse(resp)
228-
229-
// Test successful flush
230-
err := event.Flush()
231-
assert.NoError(t, err)
232-
}
233-
234-
func TestEvent_WrittenAndStatus(t *testing.T) {
235-
rec := httptest.NewRecorder()
236-
resp := NewResponse(rec)
237-
238-
event, _, _ := newTestEventForEventTest()
239-
event.SetResponse(resp)
240-
241-
// Initially not written
242-
assert.False(t, event.Written())
243-
assert.Equal(t, 0, event.Status())
244-
245-
// Write something
246-
resp.WriteHeader(http.StatusOK)
247-
_, _ = resp.Write([]byte("test"))
248-
249-
assert.True(t, event.Written())
250-
assert.Equal(t, http.StatusOK, resp.Status)
251-
}
252-
253222
func TestEvent_UserAgent(t *testing.T) {
254223
tests := []struct {
255224
name string

0 commit comments

Comments
 (0)