Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions server/controllers/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"net/http"

"github.com/auula/urnadb/server/response"
"github.com/auula/urnadb/utils"
"github.com/gin-gonic/gin"
)
Expand All @@ -35,7 +36,7 @@ type SystemInfo struct {
}

func GetHealthController(ctx *gin.Context) {
ctx.IndentedJSON(http.StatusOK, SystemInfo{
ctx.IndentedJSON(http.StatusOK, response.Ok("server is healthy", SystemInfo{
GCState: hs.RegionCompactStatus(),
KeyCount: hs.RegionInodeCount(),
DiskFree: fmt.Sprintf("%.2fGB", utils.BytesToGB(hs.GetFreeDisk())),
Expand All @@ -45,5 +46,5 @@ func GetHealthController(ctx *gin.Context) {
MemoryTotal: fmt.Sprintf("%.2fGB", utils.BytesToGB(hs.GetTotalMemory())),
SpaceTotalUsed: fmt.Sprintf("%.2fGB", utils.BytesToGB(hs.GetTotalSpaceUsed())),
DiskPercent: fmt.Sprintf("%.2f%%", hs.GetDiskPercent()),
})
}))
}
2 changes: 1 addition & 1 deletion server/controllers/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func QueryController(ctx *gin.Context) {
defer utils.ReleaseToPool(seg)
ttl, _ := seg.ExpiresIn()

ctx.IndentedJSON(http.StatusOK, response.Ok("Key metadata query completed successfully", gin.H{
ctx.IndentedJSON(http.StatusOK, response.Ok("metadata query completed successfully", gin.H{
"type": seg.GetTypeString(),
"key": seg.GetKeyString(),
"value": seg.Value,
Expand Down
8 changes: 2 additions & 6 deletions server/controllers/records.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ func GetRecordsController(ctx *gin.Context) {

defer rd.ReleaseToPool()

ctx.IndentedJSON(http.StatusOK, response.Ok("record queried successfully", gin.H{
"record": rd.Record,
}))
ctx.IndentedJSON(http.StatusOK, response.Ok("record queried successfully", rd.Record))
}

type CreateRecordRequest struct {
Expand Down Expand Up @@ -119,9 +117,7 @@ func SearchRecordsController(ctx *gin.Context) {
return
}

ctx.IndentedJSON(http.StatusOK, response.Ok("search completed successfully", gin.H{
"column": res,
}))
ctx.IndentedJSON(http.StatusOK, response.Ok("search completed successfully", res))
}

func handlerRecordsError(ctx *gin.Context, err error) {
Expand Down
8 changes: 2 additions & 6 deletions server/controllers/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ func QueryTableController(ctx *gin.Context) {
return
}

ctx.IndentedJSON(http.StatusOK, response.Ok("table queried successfully", gin.H{
"table": tab.Table,
}))
ctx.IndentedJSON(http.StatusOK, response.Ok("table queried successfully", tab.Table))
}

type PatchRowsRequest struct {
Expand Down Expand Up @@ -144,9 +142,7 @@ func QueryRowsTableController(ctx *gin.Context) {
return
}

ctx.IndentedJSON(http.StatusOK, response.Ok("table queried rows successfully", gin.H{
"rows": rows,
}))
ctx.IndentedJSON(http.StatusOK, response.Ok("table queried rows successfully", rows))
}

func RemoveRowsTabelController(ctx *gin.Context) {
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/variants.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func CreateVariantController(ctx *gin.Context) {
}

// 成功响应
ctx.IndentedJSON(http.StatusOK, response.Ok("", gin.H{
ctx.IndentedJSON(http.StatusOK, response.Ok("variant created successfully", gin.H{
"variant": new_variant.Value,
}))
}
Expand Down
2 changes: 1 addition & 1 deletion server/routes/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func SetupRoutes() *gin.Engine {
router.NoMethod(controllers.Error404Handler)

// 健康检查
router.GET("/", controllers.GetHealthController)
router.GET("/health", controllers.GetHealthController)

// 查询路由
query := router.Group("/query")
Expand Down