add threshold

This commit is contained in:
Aditya Siregar 2026-05-14 12:53:22 +07:00
parent c3317dd9ee
commit b1eef2f1d6

View File

@ -29,8 +29,8 @@ func NewDukcapilHandler(dukcapilService DukcapilService, cfg *config.Config) *Du
} }
// FaceMatch handles POST /api/v1/dukcapil/face-match (1:N face recognition). // FaceMatch handles POST /api/v1/dukcapil/face-match (1:N face recognition).
// Accepts only an image file via multipart form. All other parameters are // Accepts an image file via multipart form and an optional threshold parameter.
// generated or retrieved from configuration. // If threshold is not provided, uses the default from configuration.
func (h *DukcapilHandler) FaceMatch(c *gin.Context) { func (h *DukcapilHandler) FaceMatch(c *gin.Context) {
// Parse multipart form // Parse multipart form
file, err := c.FormFile("image") file, err := c.FormFile("image")
@ -63,11 +63,17 @@ func (h *DukcapilHandler) FaceMatch(c *gin.Context) {
// Generate transaction_id (timestamp-based random ID) // Generate transaction_id (timestamp-based random ID)
transactionID := fmt.Sprintf("TXN%d", time.Now().UnixNano()) transactionID := fmt.Sprintf("TXN%d", time.Now().UnixNano())
// Get threshold from form or use default from config
threshold := c.PostForm("threshold")
if threshold == "" {
threshold = h.config.Dukcapil.Threshold
}
// Build request with config values // Build request with config values
req := &contract.FaceMatchRequest{ req := &contract.FaceMatchRequest{
TransactionID: transactionID, TransactionID: transactionID,
TransactionSource: h.config.Dukcapil.TransactionSource, TransactionSource: h.config.Dukcapil.TransactionSource,
Threshold: h.config.Dukcapil.Threshold, Threshold: threshold,
Image: imageBase64, Image: imageBase64,
IP: h.config.Dukcapil.DefaultIP, IP: h.config.Dukcapil.DefaultIP,
} }