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).
// 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,
}