- Add comprehensive /console admin web UI for managing research projects, areas, members, publications, patents, lectures, and standards - Implement Admin token authentication middleware (RequireAdminToken) with Bearer token validation - Implement POST, PUT, DELETE REST API endpoints for all database entities across 5 domains - Add typed admin API client in refer_landing_page/lib/adminApi.ts with localStorage session persistence - Enhance E2E test runner to manage backend server lifecycle during automated tests - Pass all 12 quality gates cleanly with unanimous reviewer PASS verdicts
60 lines
1.0 KiB
Go
60 lines
1.0 KiB
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 Created(c *gin.Context, data any) {
|
|
c.JSON(http.StatusCreated, SuccessResponse{
|
|
Data: data,
|
|
})
|
|
}
|
|
|
|
func NoContent(c *gin.Context) {
|
|
c.Status(http.StatusNoContent)
|
|
}
|
|
|
|
func Unauthorized(c *gin.Context, msg string) {
|
|
Error(c, http.StatusUnauthorized, 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)
|
|
}
|