# |
Apr 19th 2017, 15:19 |
Neon1024 |
If you use a .json extension it should come back as json |
# |
Apr 19th 2017, 15:19 |
crazycoder |
*create |
# |
Apr 19th 2017, 15:19 |
crazycoder |
i will crate a midleware too |
# |
Apr 19th 2017, 15:19 |
crazycoder |
ah ok awesome |
# |
Apr 19th 2017, 15:19 |
crazycoder |
ok but after the headers? |
# |
Apr 19th 2017, 15:19 |
Neon1024 |
The exception error will be rendered as normal, but json instead of html :) |
# |
Apr 19th 2017, 15:19 |
Neon1024 |
To set the headers based on the route for my api |
# |
Apr 19th 2017, 15:18 |
Neon1024 |
I’ve used a middleware class |
# |
Apr 19th 2017, 15:18 |
crazycoder |
and what will be rendered? |
# |
Apr 19th 2017, 15:18 |
crazycoder |
k |
# |
Apr 19th 2017, 15:18 |
Neon1024 |
I always get them confused but I think it’s the Content-Type header |
# |
Apr 19th 2017, 15:18 |
Neon1024 |
You need to set the header on the response to application/json |
# |
Apr 19th 2017, 15:17 |
crazycoder |
Neon1024, how? because if i do website/blablablabla i get the html NOT found page |
# |
Apr 19th 2017, 15:17 |
Neon1024 |
I use the default exceptions, but I’ve had to make my own exception renderer to customise the json output |
# |
Apr 19th 2017, 15:17 |
Neon1024 |
Yep |
# |
Apr 19th 2017, 15:16 |
crazycoder |
Neon1024, is there a way to render the error on a json call? |
# |
Apr 19th 2017, 15:13 |
sjundee |
Hi! Anyone who has experience working with CSV? When my title row is the very first line in the file, the first element `$cols[0]` isn't found in `array_search()`. I try `$key_id = array_search('Id', $cols)`, but when it is on the very first line, it doesn't work. When it after the first line, I get what I expect. |
# |
Apr 19th 2017, 15:09 |
Neon1024 |
:D |
# |
Apr 19th 2017, 15:09 |
crazycoder |
i am working on ubuntu and deploying on ubuntu too |
# |
Apr 19th 2017, 15:09 |
crazycoder |
:D |
# |
Apr 19th 2017, 15:04 |
Neon1024 |
Not that I did that last week :p |
# |
Apr 19th 2017, 15:04 |
Neon1024 |
If like me you develop on Mac OS and go live on Ubuntu |
# |
Apr 19th 2017, 15:04 |
Neon1024 |
Otherwise you might put it into production and nothing will work |
# |
Apr 19th 2017, 15:03 |
Neon1024 |
I’d also double check that a plugin called ‘API’ works okay on case sensitive file systems |
# |
Apr 19th 2017, 15:03 |
crazycoder |
thanks! |
# |
Apr 19th 2017, 15:02 |
Neon1024 |
(y) |
# |
Apr 19th 2017, 15:02 |
Neon1024 |
Controllers are Capitalised |
# |
Apr 19th 2017, 15:02 |
crazycoder |
/ <-- |
# |
Apr 19th 2017, 15:02 |
crazycoder |
that's the problem |
# |
Apr 19th 2017, 15:02 |
Neon1024 |
Thirdly |
# |
Apr 19th 2017, 15:02 |
crazycoder |
Neon1024, yeah |
# |
Apr 19th 2017, 15:02 |
Neon1024 |
Plus, I always tend to prefix my routes with a / |
# |
Apr 19th 2017, 15:02 |
crazycoder |
but why? i wrote the action there |
# |
Apr 19th 2017, 15:02 |
Neon1024 |
Not sure the plugin name should be all UPPERCASE |
# |
Apr 19th 2017, 15:02 |
crazycoder |
yes it use the 1 as the action |
# |
Apr 19th 2017, 15:01 |
Neon1024 |
Two things stand out to me |
# |
Apr 19th 2017, 15:01 |
crazycoder |
Neon1024, {"controller":"Agents","action":"1","pass":["cv"],"plugin":"API","_ext":"json"} |
# |
Apr 19th 2017, 15:01 |
Neon1024 |
Also, beware of exposing auto-increment id’s in your api urls |
# |
Apr 19th 2017, 15:01 |
crazycoder |
Neon1024, https://gist.github.com/anonymous/4dc2c6942fef4025587de9198273c6f9 |
# |
Apr 19th 2017, 15:00 |
Neon1024 |
crazycoder: bin/cake routes check /api/agents/1/cv.json |
# |
Apr 19th 2017, 15:00 |
Neon1024 |
crazycoder: Route isn’t matchig the extension and is instead falling back to another route |