If i run the following migration: mix phoenix.gen.json Photo photos path:string
This creates a /web directory at the root path that lives outside the /lib directory but follows the same structure as ./lib/myproject_web
This does not make sense to me and doesn’t look like a correct structure. I would have though it should be merged into the structure inside the lib directory.
Can someone clarify if I am running the command wrong or this is indeed the correct file structure? thanks.
The command requires one more parameter which is the context module as documented here
and it now looks like this in my case:
mix phx.gen.json API Photo photos path:string
I’m still thinking whether i need to redefine a new context as such, but the file generation, subsequent migration and GET /api/photos worked after adding this snippet in my router.ex
` scope “/api”, MyProjectWeb do
pipe_through :browser # Use the default browser stack
get "/photos", PhotoController, :index
end`
removing the create function from PhotoController (which wasn’t compiling) and executing the migration with: mix ecto.migrate
Therefore end result is following request gives a 200 wget http://0.0.0.0:4000/api/photos