flp

flp

Url Parameter breaks Routing Pattern Matching

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

Marked As Solved

al2o3cr

al2o3cr

This is your shell trying to parse the ? - try enclosing the URL in double-quotes to avoid that behavior.

Last Post!

flp

flp

:see_no_evil:
embarrassing, you’re right

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New

We're in Beta

About us Mission Statement