Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix confusing names #579

Merged
merged 4 commits into from
Jul 19, 2017
Merged

Fix confusing names #579

merged 4 commits into from
Jul 19, 2017

Conversation

peterbourgon
Copy link
Member

Closes #526.

@ChrisHines @basvanbeek — interested in a review?

@willfaught @terinjokes — likewise, and FYI.

@peterbourgon
Copy link
Member Author

peterbourgon commented Jul 19, 2017

For the record,

#!/usr/bin/env fish

for pair in \
    "FromHTTPContext ContextToHTTP" \
    "ToHTTPContext   HTTPToContext" \
    "FromGRPCContext ContextToGRPC" \
    "ToGRPCContext   GRPCToContext" \
    "FromHTTPRequest HTTPToContext" \
    "ToHTTPRequest   ContextToHTTP" \
    "FromGRPCRequest GRPCToContext" \
    "ToGRPCRequest   ContextToGRPC"
  set fr (echo $pair | awk '{print $1}')
  set to (echo $pair | awk '{print $2}')
  echo change from $fr to $to
  find . -type f -name '*.go' -exec sed -i '' s/$fr/$to/ \{\} + # macOS syntax
end

Copy link
Member

@ChrisHines ChrisHines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good. I think the docs have some broken grammar.

@@ -17,9 +17,9 @@ const (
bearerFormat string = "Bearer %s"
)

// ToHTTPContext moves JWT token from request header to context. Particularly
// HTTPToContext moves JWT token from request header to context. Particularly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel obligated to point out that JWT is an acronym for JSON Web Token, which makes the phrase "JWT token" repetitive. I believe a more grammatically correct phrasing is "... moves a JWT from request header to context."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thank you.

@@ -17,9 +17,9 @@ const (
bearerFormat string = "Bearer %s"
)

// ToHTTPContext moves JWT token from request header to context. Particularly
// HTTPToContext moves a JWT from request header to context. Particularly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "a" article use is now inconsistent (present with "JWT", absent with "request header" and "context"), not sure if that's intentional, not a big deal.

// useful for servers.
func ToHTTPContext() http.RequestFunc {
func HTTPToContext() http.RequestFunc {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Context" seems to be in all of these names, so is it redundant? Would To/FromHTTP and To/FromGRPC be equally clear? I haven't taken a close look at the whole file, and I've never used the package, so I'm genuinely asking. :) If not, the names look good!

@peterbourgon peterbourgon merged commit 1beb0cb into master Jul 19, 2017
@peterbourgon peterbourgon deleted the fix-confusing-names branch July 19, 2017 16:55
jamesgist pushed a commit to jamesgist/kit that referenced this pull request Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants