mirror of
https://github.com/MedzikUser/go-pingbot
synced 2024-08-14 23:57:07 +00:00
- Added ctx to backend ping - Log changed Stderr to Stdout - Added cluster functional - Updated more files
38 lines
595 B
Go
38 lines
595 B
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"gitlab.com/gaming0skar123/go/pingbot/database/mongo"
|
|
)
|
|
|
|
func GetAll(c *gin.Context) {
|
|
results, err := mongo.GetAll()
|
|
// Error Handling
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, json{
|
|
"success": false,
|
|
"message": "Error fetching URLs!",
|
|
})
|
|
fmt.Println(err)
|
|
|
|
return
|
|
}
|
|
|
|
// DB Is Empty
|
|
if results == nil {
|
|
c.JSON(http.StatusNotFound, json{
|
|
"success": false,
|
|
"message": "Database is empty!",
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, json{
|
|
"success": true,
|
|
"db": results,
|
|
})
|
|
}
|