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

Add Freckle.App.Http (setRequestMethod) #176

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

mjgpy3
Copy link
Contributor

@mjgpy3 mjgpy3 commented Jun 21, 2024

Why?

As far as I know there are currently 2 ways to use a non-GET request method:

  1. including method in the request string (e.g. parseRequest_ $ "POST " <> url)
  2. importing lower-level HTTP module and setting the field directly (e.g. req { HTTP.method = "POST"})

2 breaks the centralization we're providing with this module by requiring consumers to import an internal thing.

Also both of these are stringly typed, producing a runtime error if a mistake is made, exs. forgotten space, or casing:

Note that the request method must be provided as all capital letters.

^ from http-conduit's docs.

Note

We could just re-export Network.HTTP.Simple (setRequestMethod), however, it still has the stringly-typed problem (it takes a ByteString). StdMethod gives us nice type-safety and covers all our current (and I'd bet future) use-cases.

**Why?**

As far as I know there are currently 2 ways to use a non-`GET` request method:
1. including method in the request string (e.g. `parseRequest_ $ "POST " <> url`)
2. importing lower-level HTTP module and setting the field directly (e.g. `req {
 HTTP.method = "POST"}`)

**2** breaks the centralization we're providing with this module by requiring
consumers to import an internal thing.

Also both of these are stringly typed, producing a runtime error if a mistake is
made, exs. forgotten space, or casing:

> Note that the request method must be provided as all capital letters.

^ from `http-conduit`'s docs.

**Note**

We could just re-export `Network.HTTP.Simple (setRequestMethod)`, however, still
has the stringly-typed problem (it takes a `ByteString`). `StdMethod` gives us
nice type-safety and covers all our current (and I'd bet future) use-cases.
@mjgpy3 mjgpy3 requested a review from chris-martin June 21, 2024 18:56
Copy link
Member

@pbrisbin pbrisbin left a comment

Choose a reason for hiding this comment

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

We could just re-export Network.HTTP.Simple (setRequestMethod), however, it still has the stringly-typed problem

Haha, I have never once thought or cared about this problem. I just use that method and (I guess) always with canonical values like "GET". We should open a PR to make that setRequestMethod do what we're doing here, IMO.

@mjgpy3 mjgpy3 merged commit 60e231d into main Jun 24, 2024
6 of 7 checks passed
@mjgpy3 mjgpy3 deleted the gilli/add-request-method-modifier branch June 24, 2024 15:23
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.

2 participants