Skip to content

Commit 82c2e41

Browse files
committed
feat: ResponseWriter 인터페이스에 IsCommitted() 메서드 추가 및 EchoResponseWriter에서 구현
1 parent 167e209 commit 82c2e41

5 files changed

Lines changed: 17 additions & 6 deletions

File tree

core/response_writer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ type ResponseWriter interface {
88
SetHeader(key, value string)
99
AddHeader(key, value string)
1010

11+
// 응답이 이미 커밋(헤더/바디 작성 시작)되었는지 여부
12+
IsCommitted() bool
13+
1114
// 상태 코드만 기록 (body 없음)
1215
WriteStatus(status int) error
1316

internal/adapter/echo/context_impl.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ func (e *echoContext) Context() context.Context {
3030
return e.reqCtx
3131
}
3232

33+
func (e *echoContext) Request() core.RequestContext {
34+
return e
35+
}
36+
3337
func (e *echoContext) Bind(out any) error {
3438
return e.echo.Bind(out)
3539
}

internal/adapter/echo/response_writer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ func (w *EchoResponseWriter) AddHeader(key, value string) {
2828
w.ctx.Response().Header().Add(key, value)
2929
}
3030

31+
func (w *EchoResponseWriter) IsCommitted() bool {
32+
return w.ctx.Response().Committed
33+
}
34+
3135
func (w *EchoResponseWriter) WriteStatus(status int) error {
3236
w.ctx.Response().WriteHeader(status)
3337
return nil

internal/bootstrap/bootstrap.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,9 @@ func Run(config Config) error {
288288
}()
289289
}
290290

291-
log.Println("[Bootstrap] 컨트롤러 의존성 Warm-up 시작")
292-
// Warm-Up Component
293-
if err := container.WarmUp(nil); err != nil {
294-
// Warm-up 실패시 panic
295-
panic(err)
296-
}
297291
// Consumer 컨트롤러 Warm-up
298292
if config.ConsumerRegistry != nil {
293+
log.Println("[Bootstrap] Consumer 컨트롤러 의존성 Warm-up 시작")
299294
var consumerTypes []reflect.Type
300295
for _, reg := range config.ConsumerRegistry.Registrations() {
301296
consumerTypes = append(consumerTypes, reg.Meta.ControllerType)

internal/pipeline/pipeline.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ func (p *Pipeline) handleExecutionError(ctx core.ExecutionContext, err error) {
277277
return
278278
}
279279

280+
// ReturnValueHandler 등에서 이미 응답이 커밋된 경우 이중 응답을 방지한다.
281+
if rw.IsCommitted() {
282+
return
283+
}
284+
280285
var httpErr *httperr.HTTPError
281286
if errors.As(err, &httpErr) {
282287
rw.WriteJSON(

0 commit comments

Comments
 (0)