init dataleak sample feature

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2025-10-04 16:33:03 +02:00
parent d462ff791e
commit c036649a70
6 changed files with 193 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ import (
"time"
"github.com/anotherhadi/eleakxir/backend/search"
"github.com/anotherhadi/eleakxir/backend/search/dataleak"
"github.com/anotherhadi/eleakxir/backend/server"
"github.com/gin-gonic/gin"
)
@@ -116,6 +117,20 @@ func routes(s *server.Server, cache *map[string]*search.Result, searchQueue chan
}
c.JSON(http.StatusOK, r)
})
s.Router.GET("/dataleak/sample", func(c *gin.Context) {
path := c.Query("path")
if path == "" {
c.JSON(http.StatusBadRequest, gin.H{"Error": "path is required"})
return
}
sample, err := dataleak.GetDataleakSample(*s, path)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"Error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"Sample": sample})
})
}
func Init(s *server.Server) {