mindseyeblind
I’m building an API connecting with various front-end UI’s. I have a context that is still being built while I hash out the business logic properly with non-development teams BUT in the meanwhile I need to serve at least a sample version of the API data (the “show” action) at the right location so that frontend development can continue.
The API would be hit at /models/1, 1 being the sample ID, and then serve up a JSON file containing all the static data. I have a static YML file I’ve been using to construct this sample, but how exactly would I serve it? As a static asset?
I’m thinking of replacing the default show action with an implementation that disregards the ID parameter and simply uses Plug.Conn.send_file/5 to serve sample_model.json but I don’t think this is the right way of going about this.
Alternatively, maybe I should short-circuit the model = Context.get_model(id) cast and directly specify a map inside there. This would look quite dirty (almost doubling the line-length of the file) but it’s temporary anyway.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
mindseyeblind
Solved - all I had to do was overwrite the
model_view.render/2function that begins withIt’s dirty but it works.