Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/api/handlers/app_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ func HandleAppLogs(
Follow: follow,
}

// Handle HEAD requests with early return
if r.Method == http.MethodHead {
render.EncodeResponse(w, http.StatusOK, nil)
return
}

sseStream, err := render.NewSSEStream(r.Context(), w)
if err != nil {
slog.Error("Unable to create SSE stream", slog.String("error", err.Error()))
Expand Down
6 changes: 6 additions & 0 deletions internal/api/handlers/app_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ func HandlerAppStatus(
cfg config.Configuration,
) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Handle HEAD requests with early return
if r.Method == http.MethodHead {
render.EncodeResponse(w, http.StatusOK, nil)
return
}

sseStream, err := render.NewSSEStream(r.Context(), w)
if err != nil {
slog.Error("Unable to create SSE stream", slog.String("error", err.Error()))
Expand Down
11 changes: 8 additions & 3 deletions internal/api/handlers/system_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ import (

func HandleSystemResources() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
sseStream, err := render.NewSSEStream(ctx, w)
// Handle HEAD requests with early return
if r.Method == http.MethodHead {
render.EncodeResponse(w, http.StatusOK, nil)
return
}

sseStream, err := render.NewSSEStream(r.Context(), w)
if err != nil {
slog.Error("Unable to create SSE stream", slog.String("error", err.Error()))
render.EncodeResponse(w, http.StatusInternalServerError, models.ErrorResponse{Details: "unable to create SSE stream"})
return
}
defer sseStream.Close()

resources, err := orchestrator.SystemResources(ctx, nil)
resources, err := orchestrator.SystemResources(r.Context(), nil)
if err != nil {
sseStream.SendError(render.SSEErrorData{
Code: render.InternalServiceErr,
Expand Down
7 changes: 7 additions & 0 deletions internal/api/handlers/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ func HandleUpdateApply(updater *update.Manager) http.HandlerFunc {

func HandleUpdateEvents(updater *update.Manager) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// HOTFIX: app-lab use HEAD requests to check endpoint availability
// so we need to handle them here by early return without opening SSE stream
if r.Method == http.MethodHead {
render.EncodeResponse(w, http.StatusOK, nil)
return
}

sseStream, err := render.NewSSEStream(r.Context(), w)
if err != nil {
slog.Error("Unable to create SSE stream", slog.String("error", err.Error()))
Expand Down