Files
landing_page/backend/internal/httpx/response.go
T
Godopu fb6881070c feat(backend,docker,docs): implement Go/Gin/SQLite REST API server, Docker containerization, and architecture specifications
- Implement standalone Go backend API server using Gin and pure-Go SQLite (modernc.org/sqlite)
- Add 11-table schema DDL migrations (000001_init.up.sql) based on DATA_TABLE.md
- Add seed data ingestion tool (cmd/seed) and static TypeScript content exporter (cmd/export-content)
- Add configuration loader (internal/config) supporting environment variables and .env files (HOST, PORT, DB_PATH, GIN_MODE, CORS_ALLOW_ORIGINS, AUTO_MIGRATE)
- Add lightweight multi-stage Dockerfile and docker-compose.yml with persistent SQLite volume
- Add comprehensive architecture specification (ARCHITECTURE.md) and REST API interface specification (API_INTERFACE.md)
- Harmonize frontend publications page to consume isHighlight flag from database-synced content
2026-08-24 17:34:51 +09:00

46 lines
758 B
Go

package httpx
import (
"net/http"
"github.com/gin-gonic/gin"
)
type ErrorDetail struct {
Message string `json:"message"`
}
type ErrorResponse struct {
Error ErrorDetail `json:"error"`
}
type SuccessResponse struct {
Data any `json:"data"`
}
func OK(c *gin.Context, data any) {
c.JSON(http.StatusOK, SuccessResponse{
Data: data,
})
}
func Error(c *gin.Context, status int, msg string) {
c.JSON(status, ErrorResponse{
Error: ErrorDetail{
Message: msg,
},
})
}
func BadRequest(c *gin.Context, msg string) {
Error(c, http.StatusBadRequest, msg)
}
func NotFound(c *gin.Context, msg string) {
Error(c, http.StatusNotFound, msg)
}
func InternalServerError(c *gin.Context, msg string) {
Error(c, http.StatusInternalServerError, msg)
}