Hey guys, I am trying to implement a simple json api that also allows for filtering via url parameters. I’m stuck and surprised why it doesn’t work but I am quite sure it’s a stupid mistake. Maybe someone can help me.
Router.ex
pipeline :api do
plug :accepts, ["json"]
end
scope "/api", TrainingWeb do
scope "/v1" do
pipe_through :api
get "/exercises", ExerciseController, :index
end
end
controller.ex
def index(conn, _params) do
exercises = Repo.all(Exercise)
render(conn, "index.json", exercises: exercises)
end
If I now query that with curl, I get the following responses:
curl http://localhost:4000/api/v1/exercises
=> works, I get the full list
curl http://localhost:4000/api/v1/exercises?filters=123
zsh: no matches found: http://localhost:4000/api/v1/exercises?filters=123