From b1eef2f1d6a9caeb3bc132161f38f216fa7794d8 Mon Sep 17 00:00:00 2001 From: Aditya Siregar Date: Thu, 14 May 2026 12:53:22 +0700 Subject: [PATCH] add threshold --- internal/handler/dukcapil_handler.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/handler/dukcapil_handler.go b/internal/handler/dukcapil_handler.go index 2a1b5a4..e5d0347 100644 --- a/internal/handler/dukcapil_handler.go +++ b/internal/handler/dukcapil_handler.go @@ -29,8 +29,8 @@ func NewDukcapilHandler(dukcapilService DukcapilService, cfg *config.Config) *Du } // FaceMatch handles POST /api/v1/dukcapil/face-match (1:N face recognition). -// Accepts only an image file via multipart form. All other parameters are -// generated or retrieved from configuration. +// Accepts an image file via multipart form and an optional threshold parameter. +// If threshold is not provided, uses the default from configuration. func (h *DukcapilHandler) FaceMatch(c *gin.Context) { // Parse multipart form file, err := c.FormFile("image") @@ -63,11 +63,17 @@ func (h *DukcapilHandler) FaceMatch(c *gin.Context) { // Generate transaction_id (timestamp-based random ID) 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 req := &contract.FaceMatchRequest{ TransactionID: transactionID, TransactionSource: h.config.Dukcapil.TransactionSource, - Threshold: h.config.Dukcapil.Threshold, + Threshold: threshold, Image: imageBase64, IP: h.config.Dukcapil.DefaultIP, }