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, }