-
Notifications
You must be signed in to change notification settings - Fork 174
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
Include cache headers in 304 responses #2061
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! So it was just a bug from the ordering of the imports?
@@ -351,7 +351,7 @@ defmodule Electric.Plug.ServeShapePlug do | |||
get_req_header(conn, "if-none-match") | |||
|> Enum.flat_map(&String.split(&1, ",")) | |||
|> Enum.map(&String.trim/1) | |||
|> Enum.map(&String.trim(&1, ~S|"|)) | |||
|> Enum.map(&String.trim(&1, <<?">>)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's doing the same thing as before but is easier to read to my Elixir eyes.
<<...>>
is a container syntax for binaries in Elixir. By default, every element is treated as a byte:
<<80, 79, 80>> == "POP"
The ?...
syntax is a parser feature the replaces itself with the ASCII code of the character, so:
?P == 80
?O == 79
?" == 34
The <<...>>
syntax is used almost every time when you need to parse a string while doing different things for different classes of characters. See https://github.com/electric-sql/electric/blob/main/packages/sync-service/lib/electric/postgres/identifiers.ex for some examples.
I much prefer using it over ad-hoc delimiters with the ~S
sigil because it's so common in Elixir code already. TO be fair, we also have some occurrences of "\""
in the code, it's yet another way to write the same string containing a single double-quote character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah neat!
I've changed the order of plug applications, which is simply changing the order of function application as each plug is a function. Now, we first set the response headers on the |
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Fixes #2059