-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decode group_name by GroupNameDecoder
- Use GroupNameDecoder (Plug) to decode group_name instead implementation inside controllers FIX #904 Signed-off-by: Gabriele Ghio <[email protected]>
- Loading branch information
1 parent
c83724f
commit 01e0fff
Showing
4 changed files
with
21 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
apps/astarte_appengine_api/lib/astarte_appengine_api_web/plug/group_name_decoder.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule Astarte.AppEngine.APIWeb.Plug.GroupNameDecoder do | ||
@moduledoc """ | ||
This plug decodes a group name, which may have been coded | ||
to remove the forward slash | ||
""" | ||
def init(default), do: default | ||
|
||
def call(%Plug.Conn{path_params: %{"group_name" => group_name}} = conn, _) do | ||
%Plug.Conn{conn | path_params: %{conn.path_params | "group_name" => URI.decode(group_name)}} | ||
end | ||
|
||
def call(conn, _), do: conn | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters