admin_dashboard_backend/pkg/handlers/welcome/welcome.go

25 lines
445 B
Go

package welcome
import (
"encoding/json"
"net/http"
)
type Response struct {
Message string `json:"message"`
}
func HandlersWelcome(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
response := Response{
Message: "Welcome to the API!",
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
}