feat: add getclientcredential func to http handler
This commit is contained in:
parent
18c2b5986b
commit
a21afc9719
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
pb "git.esin.io/lab/weixin/protobuf/clientapi/mp/auth"
|
pb "git.esin.io/lab/weixin/protobuf/clientapi/mp/auth"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -43,6 +44,7 @@ func run() error {
|
|||||||
http.HandleFunc("/token", h.exchangeToken)
|
http.HandleFunc("/token", h.exchangeToken)
|
||||||
http.HandleFunc("/userinfo", h.getUserinfo)
|
http.HandleFunc("/userinfo", h.getUserinfo)
|
||||||
http.HandleFunc("/userinfo/sync", h.syncUserinfo)
|
http.HandleFunc("/userinfo/sync", h.syncUserinfo)
|
||||||
|
http.HandleFunc("/clientcredential", h.getClientCredential)
|
||||||
|
|
||||||
return http.ListenAndServe(":"+lisPort, nil)
|
return http.ListenAndServe(":"+lisPort, nil)
|
||||||
}
|
}
|
||||||
@ -111,3 +113,12 @@ func (h restHandler) syncUserinfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
json.NewEncoder(w).Encode(resp)
|
json.NewEncoder(w).Encode(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h restHandler) getClientCredential(w http.ResponseWriter, r *http.Request) {
|
||||||
|
resp, err := h.client.GetClientCredential(r.Context(), &emptypb.Empty{})
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
json.NewEncoder(w).Encode(resp)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user