Last active
March 1, 2018 12:59
-
-
Save erez-rabih/6b3709d977202d0f44e71232f633d5c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
defmodule Plug.Support.Router do | |
import Plug.Conn | |
use Plug.Router | |
import Plug.Support.Validators, | |
only: [validate_integer: 1, validate_boolean: 1, on_error_fn: 2, json_resp: 3] | |
plug :match | |
plug Plug.Validator, on_error: &on_error_fn/2 | |
plug :dispatch | |
get "/users/:id", | |
private: %{validate: %{id: &validate_integer/1, active: &validate_boolean/1}} do | |
json_resp(conn, 200, %{id: 1, name: "user1"}) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment