Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

add mock api

aichy1266b13eca4ef4d
diff --git a/internal/router/ui.go b/internal/router/ui.go
index 99bcaf07..1b5b2429 100644
--- a/internal/router/ui.go
+++ b/internal/router/ui.go
@@ -4,6 +4,7 @@ import (
"embed"
"fmt"
"io/fs"
+ "math/rand"
"net/http"
"os"
@@ -93,11 +94,29 @@ func (a *UIRouter) Register(r *gin.Engine) {
})
r.POST("/installation/db/check", func(c *gin.Context) {
- handler.HandleResponse(c, nil, gin.H{})
+ num := rand.Intn(10)
+ if num > 5 {
+ err := fmt.Errorf("connection error")
+ handler.HandleResponse(c, err, gin.H{})
+ } else {
+ handler.HandleResponse(c, nil, gin.H{
+ "connection_success": true,
+ })
+ }
})
r.POST("/installation/config-file/check", func(c *gin.Context) {
- handler.HandleResponse(c, nil, gin.H{})
+ num := rand.Intn(10)
+ if num > 5 {
+ handler.HandleResponse(c, nil, gin.H{
+ "exist": true,
+ })
+ } else {
+ handler.HandleResponse(c, nil, gin.H{
+ "exist": false,
+ })
+ }
+
})
r.POST("/installation/init", func(c *gin.Context) {