-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Reworked args on route to be a list so user can describe args function #30
base: main
Are you sure you want to change the base?
Conversation
@@ -47,6 +47,7 @@ defmodule Maverick.Api do | |||
@otp_app Keyword.fetch!(opts, :otp_app) | |||
@root_scope opts |> Keyword.get(:root_scope, "/") | |||
@router Module.concat(__MODULE__, Router) | |||
@modules opts |> Keyword.get(:modules, []) |
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.
i don't know why i have the opts inside the parens on line 47 but i'm piping them in on line 48; i'd just get rid of all of those single-pipes, no idea what i was thinking
@@ -1,7 +1,7 @@ | |||
defmodule Maverick.TestRoute1 do | |||
use Maverick, scope: "/route1" | |||
|
|||
@route path: "multiply", args: {:required_params, [:num1, :num2]}, error: 403 | |||
@route path: "multiply", args: [:params], error: 403 |
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.
this is transitional until you get to the more explicit "required non-nil values" you mentioned?
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.
Yes, want to get basic argument handling done, and then come back and add required params.
defp arg(conn, :conn), do: conn | ||
|
||
defp arg(conn, {parameter, :required}) do | ||
get_in(conn.params, List.wrap(parameter)) |
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.
this is the same as the non-required version below; should this blow up if the get_in
fails?
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.
yeah, I forgot I had this in there, I will pull it out of this PR and deal with required params later.
def validate(args) do | ||
args | ||
end |
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.
placeholder?
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.
yes
|> :application.get_key(:modules) | ||
@spec list_routes(Maverick.api(), Maverick.root_scope()) :: [t()] | ||
def list_routes(api, root_scope) do | ||
api.list_modules() |
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.
good catch; this will help prevent really big apps from searching through hundreds to thousands of modules
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.
Approved unless this particular branch is still WIP
is to receive
also cleaned up test helpers