-
Notifications
You must be signed in to change notification settings - Fork 601
Open
Labels
Description
I’m working on a library that accepts status codes (integer or atom) and want to verify that valid status values are used.
I can do this with:
try
Plug.Conn.Status.code(value)
true
rescue
_ -> false
endBut this seems like it might be more generally useful if built into Plug.Status. Would a PR for this feature be accepted?
As well, it seems that Plug.Conn.Status.code/1 for the integer case isn’t entirely correct given the error raised with an unknown value in reason_phrase/1:
def code(integer) when integer in 100..999 do
integer
end
…
That feels like it should be instead
```elixir
@valid_status_codes Map.keys(Map.merge(statuses, custom_statuses))
def code(integer) when integer in @valid_status_codes do
integer
end