Initial commit

This commit is contained in:
2025-10-08 16:49:13 +00:00
commit 7274adfa0d
12 changed files with 624 additions and 0 deletions

43
handlers.go Normal file
View File

@@ -0,0 +1,43 @@
package main
import (
"encoding/json"
"net/http"
)
type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
}
// GetHealth godoc
// @Summary Health check
// @Description Check if the API is running
// @Tags health
// @Produce json
// @Success 200 {object} map[string]string
// @Router /health [get]
func GetHealth(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
}
// GetUsers godoc
// @Summary Get users
// @Description Get list of all users
// @Tags users
// @Produce json
// @Success 200 {array} User
// @Failure 401 {object} map[string]string
// @Security ApiKeyAuth
// @Router /users [get]
func GetUsers(w http.ResponseWriter, r *http.Request) {
users := []User{
{ID: 1, Name: "John Doe", Email: "john@example.com"},
{ID: 2, Name: "Jane Smith", Email: "jane@example.com"},
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(users)
}