build: Build a simple Go API server with: 1. GET /api/health endpoint 2. GET...
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending
This commit is contained in:
parent
296401abbc
commit
c7f7f656c2
@ -116,6 +116,16 @@ func main() {
|
||||
|
||||
// Routes
|
||||
r.Route("/api", func(r chi.Router) {
|
||||
// Health check
|
||||
r.Get("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||
jsonResponse(w, http.StatusOK, APIResponse{Success: true, Data: "OK"})
|
||||
})
|
||||
|
||||
// Hello World
|
||||
r.Get("/hello", func(w http.ResponseWriter, r *http.Request) {
|
||||
jsonResponse(w, http.StatusOK, APIResponse{Success: true, Data: "Hello World"})
|
||||
})
|
||||
|
||||
r.Get("/tasks", func(w http.ResponseWriter, r *http.Request) {
|
||||
tasks := store.GetAll()
|
||||
jsonResponse(w, http.StatusOK, APIResponse{Success: true, Data: tasks})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user