Skip to content

Commit add33de

Browse files
Added search handler
1 parent 90c357a commit add33de

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

internal/search/handlers.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
package search
22

33
import (
4-
"fmt"
5-
"net/http"
64
"encoding/json"
5+
"net/http"
6+
7+
"go.uber.org/zap"
78
)
89

9-
/* handler to return list of all users in LDAP server */
10+
/* handler to return list of users that match the query in LDAP server */
1011
func SearchUsersHandler(w http.ResponseWriter, r *http.Request) {
1112
/* fetch all users from LDAP server */
12-
users, err := GetAllUsersFromLDAP()
13+
query := r.URL.Query().Get("q")
14+
users, err := GetAllUsersFromLDAP(query)
1315
if err != nil {
14-
http.Error(w, fmt.Sprintf("LDAP error: %v", err), http.StatusInternalServerError)
16+
zap.L().Error("LDAP error",
17+
zap.Error(err),
18+
)
19+
http.Error(w, "LDAP error", http.StatusInternalServerError)
1520
return
1621
}
1722

0 commit comments

Comments
 (0)