-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
Hi @gmlewis ! 👋
I've been exploring the codebase and noticed a pattern in how HTTP methods are handled throughout the library. I'm curious about the design decision and would love to understand the reasoning better.
What I Observed
The library currently uses a mixed approach for HTTP methods:
- String literals: Many files use
"GET"
,"POST"
,"PUT"
,"DELETE"
,"PATCH"
directly - net/http constants: Some files use
http.MethodGet
,http.MethodPost
, etc.
Examples:
// String literals (found in many files)
req, err := s.client.NewRequest("GET", u, nil)
req, err := s.client.NewRequest("POST", u, opts)
// net/http constants (found in some files)
req, err := s.client.NewRequest(http.MethodGet, u, nil)
req, err := http.NewRequest(http.MethodPost, u.String(), body)
My Questions
-
Are there specific reasons for preferring string literals in some cases and constants in others?
-
Would you be open to contributions that standardize this usage? (I'm not suggesting changes yet, just curious about the maintainers' thoughts)
Note
I'm not proposing any changes at this point - I'm just trying to understand the design philosophy and whether this is something the maintainers would like to see addressed in the future.
Thanks!
gmlewis
Metadata
Metadata
Assignees
Labels
No labels