Skip to content

Commit

Permalink
refactor: ヘルスチェック関連のコードの位置を変更
Browse files Browse the repository at this point in the history
  • Loading branch information
KinjiKawaguchi committed Mar 23, 2024
1 parent 34551a0 commit d02645b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
20 changes: 0 additions & 20 deletions typing-server/api/controller/system/health.go

This file was deleted.

14 changes: 14 additions & 0 deletions typing-server/api/handler/health.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package handler

import (
"log/slog"
"net/http"
)

func HealthCheck(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte("API is running"))
if err != nil {
slog.Error("failed to write response: %v", err)
}
}
3 changes: 1 addition & 2 deletions typing-server/api/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"net/http"

"github.com/go-chi/chi/v5"
"github.com/su-its/typing/typing-server/api/controller/system"
"github.com/su-its/typing/typing-server/api/handler"
)

func SetupRouter() http.Handler {
r := chi.NewRouter()

r.Get("/health", system.HealthCheck)
r.Get("/health", handler.HealthCheck)

r.Get("/users", handler.GetUsers)

Expand Down

0 comments on commit d02645b

Please sign in to comment.