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
This is your shell trying to parse the ? - try enclosing the URL in double-quotes to avoid that behavior.
3
Last Post!
flp
Popular in Questions
Hello, how can I check the Phoenix version ?
Thanks !
New
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
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
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
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
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
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
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
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
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
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
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
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









