Skip to content

Commit

Permalink
Some code improvements (#868)
Browse files Browse the repository at this point in the history
* Simplify some functions.
* strings.ToLower comparison changed to strings.EqualFold.
  • Loading branch information
sosiska authored and peterbourgon committed May 6, 2019
1 parent da68e76 commit fbab14b
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 168 deletions.
2 changes: 1 addition & 1 deletion auth/jwt/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func ContextToGRPC() grpc.ClientRequestFunc {

func extractTokenFromAuthHeader(val string) (token string, ok bool) {
authHeaderParts := strings.Split(val, " ")
if len(authHeaderParts) != 2 || strings.ToLower(authHeaderParts[0]) != bearer {
if len(authHeaderParts) != 2 || !strings.EqualFold(authHeaderParts[0], bearer) {
return "", false
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions metrics/generic/generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestCounter(t *testing.T) {
if want, have := name, counter.Name; want != have {
t.Errorf("Name: want %q, have %q", want, have)
}
value := func() float64 { return counter.Value() }
value := counter.Value
if err := teststat.TestCounter(counter, value); err != nil {
t.Fatal(err)
}
Expand All @@ -45,7 +45,7 @@ func TestGauge(t *testing.T) {
if want, have := name, gauge.Name; want != have {
t.Errorf("Name: want %q, have %q", want, have)
}
value := func() float64 { return gauge.Value() }
value := gauge.Value
if err := teststat.TestGauge(gauge, value); err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit fbab14b

Please sign in to comment.