1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-12 22:07:47 +02:00

improve code quality (#2128)

* Fix inefficient string comparison

* Fix unnecessary calls to Printf

* Canonicalize header key

* Replace `t.Sub(time.Now())` with `time.Until`

* Remove unnecessary blank (_) identifier

* Remove unnecessary use of slice

* Remove unnecessary comparison with bool
This commit is contained in:
Shubhendra Singh Chauhan
2021-02-25 14:00:35 +05:30
committed by GitHub
parent 0f0ace1a44
commit 26b859c4f9
9 changed files with 10 additions and 10 deletions

View File

@ -122,7 +122,7 @@ func (h *rpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
md["Host"] = r.Host
md["Method"] = r.Method
// get canonical headers
for k, _ := range r.Header {
for k := range r.Header {
// may be need to get all values for key like r.Header.Values() provide in go 1.14
md[textproto.CanonicalMIMEHeaderKey(k)] = r.Header.Get(k)
}

View File

@ -38,7 +38,7 @@ func serveWebsocket(ctx context.Context, w http.ResponseWriter, r *http.Request,
}
hdr := make(http.Header)
if proto, ok := r.Header["Sec-WebSocket-Protocol"]; ok {
if proto, ok := r.Header["Sec-Websocket-Protocol"]; ok {
for _, p := range proto {
switch p {
case "binary":