Files
superidou 5759c1862e AI Gateway Go 0.10.0 源码快照 + 旗舰版需求规划报告
M0-M7 已完成:核心网关(身份/RBAC/TOTP/OIDC/SAML/Provider/配额/路由/内容策略/审计/定价)+ 资源市场(MCP/Skills/数字员工)。
含 22 个 PostgreSQL 迁移、管理端/门户端前端源码、OpenAPI 契约、部署 compose。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-12 11:45:54 +08:00

27 lines
662 B
Go

package apiresponse
import (
"encoding/json"
"net/http"
)
type Envelope struct {
Code int `json:"code"`
Message string `json:"msg"`
Data any `json:"data,omitempty"`
}
func OK(writer http.ResponseWriter, data any) {
Write(writer, http.StatusOK, Envelope{Code: http.StatusOK, Message: "success", Data: data})
}
func Error(writer http.ResponseWriter, status int, message string) {
Write(writer, status, Envelope{Code: status, Message: message})
}
func Write(writer http.ResponseWriter, status int, value any) {
writer.Header().Set("Content-Type", "application/json")
writer.WriteHeader(status)
_ = json.NewEncoder(writer).Encode(value)
}