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

introduce multi-path configuration #1

Merged
merged 3 commits into from
Jul 24, 2018
Merged

Conversation

mindreframer
Copy link
Contributor

problem:

  • sometimes you might have more than one healthcheck, eg. in Kubernetes we have readiness / liveliness checks

solution:

  • extend the api to accept list of paths to ignore + tests

problem: 
- sometimes you might have more than one healthcheck, eg. in Kubernetes we have readiness / liveliness checks

solution: 
- extend the api to accept list of paths to ignore + tests
Copy link
Contributor

@amencarini amencarini left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this contribution, it's great stuff 😄 Have a look at my comments and let me know what you think. I'll quickly set up CI on this too, as I just noticed it's not yet running.

@@ -8,9 +8,18 @@ defmodule Plug.QuietLogger do
%{log: log, path: path}
end

def call(%{request_path: path} = conn, %{log: :info, path: paths}) when is_list(paths) do
cond do
Copy link
Contributor

Choose a reason for hiding this comment

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

I normally prefer an if statement instead of a binary cond, it feels a bit clearer!

if path in paths, do: conn, else: Plug.Logger.call(conn, log)

What do you think?

@@ -8,9 +8,18 @@ defmodule Plug.QuietLogger do
%{log: log, path: path}
end

def call(%{request_path: path} = conn, %{log: :info, path: paths}) when is_list(paths) do
Copy link
Contributor

Choose a reason for hiding this comment

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

The hardcoded :info would prevent the configurability of the log level. Is that intended?

true -> Plug.Logger.call(conn, :info)
end

conn
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this at the end of the function, you can safely rely on what's returned from the previous cond/if statement 🙂

@mindreframer
Copy link
Contributor Author

@amencarini thanks for the feedback, looks cleaner now!

@amencarini amencarini merged commit e0764f0 into Driftrock:master Jul 24, 2018
@amencarini
Copy link
Contributor

Amazing, thank you so much, will push to hex momentarily 🌈

@mindreframer
Copy link
Contributor Author

mindreframer commented Jul 24, 2018 via email

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.

None yet

2 participants