malscan/rest.go
Yvan Janssens 8a61a52fa1
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Implement /status API endpoint
2023-04-07 14:22:47 +02:00

44 lines
896 B
Go

package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
type status_response struct {
Scanning_engine string `json:"scanning_engine"`
Signature_count int `json:"signature_count"`
Sanity_check bool `json:"sanity_check"`
}
type scan_response struct {
Malware_detected bool `json:"malware_detected"`
Malware_name string `json:"malware_name"`
Engine status_response `json:"engine"`
}
func scan_api(c *gin.Context) {
}
func status_api(c *gin.Context) {
scannerIsSane, sigCount := sanity_check()
responseData := status_response{
Sanity_check: scannerIsSane,
Signature_count: sigCount,
Scanning_engine: "clamav",
}
c.IndentedJSON(http.StatusOK, responseData)
}
func start_api() {
gin.SetMode(gin.ReleaseMode)
router := gin.Default()
router.PUT("/scan", scan_api)
router.GET("/status", status_api)
router.Run(":8080")
}