/
http.go
36 lines (31 loc) · 1.01 KB
/
http.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package kyc
import (
"context"
"net/http"
commonhttp "github.com/cloudtrust/common-service/http"
"github.com/cloudtrust/common-service/log"
"github.com/cloudtrust/keycloak-bridge/internal/constants"
"github.com/go-kit/kit/endpoint"
http_transport "github.com/go-kit/kit/transport/http"
)
// Regular expressions
const (
RegExpUserName = constants.RegExpUsername
RegExpUserID = constants.RegExpID
RegExpGroupIds = constants.RegExpGroupIds
)
// MakeKYCHandler make an HTTP handler for the KYC endpoint.
func MakeKYCHandler(e endpoint.Endpoint, logger log.Logger) *http_transport.Server {
pathParams := map[string]string{"userId": RegExpUserID}
queryParams := map[string]string{
"username": RegExpUserName,
"groupIds": RegExpGroupIds,
}
return http_transport.NewServer(e,
func(ctx context.Context, req *http.Request) (interface{}, error) {
return commonhttp.DecodeRequest(ctx, req, pathParams, queryParams)
},
commonhttp.EncodeReply,
http_transport.ServerErrorEncoder(commonhttp.ErrorHandler(logger)),
)
}