/
http.go
35 lines (29 loc) · 1.05 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
package account
import (
"context"
"net/http"
commonhttp "github.com/cloudtrust/common-service/http"
"github.com/cloudtrust/common-service/log"
account_api "github.com/cloudtrust/keycloak-bridge/api/account"
"github.com/go-kit/kit/endpoint"
http_transport "github.com/go-kit/kit/transport/http"
)
// MakeAccountHandler make an HTTP handler for an Account endpoint.
func MakeAccountHandler(e endpoint.Endpoint, logger log.Logger) *http_transport.Server {
return http_transport.NewServer(e,
decodeAccountRequest,
commonhttp.EncodeReply,
http_transport.ServerErrorEncoder(commonhttp.ErrorHandler(logger)),
)
}
// decodeEventsRequest gets the HTTP parameters and body content
func decodeAccountRequest(ctx context.Context, req *http.Request) (interface{}, error) {
var pathParams = map[string]string{
"credentialID": account_api.RegExpID,
"previousCredentialID": account_api.RegExpIDNullable,
}
var queryParams = map[string]string{
"realm_id": account_api.RegExpRealmName,
}
return commonhttp.DecodeRequest(ctx, req, pathParams, queryParams)
}