# |
Apr 19th 2017, 15:41 |
Neon1024 |
It exists in the CakePHP core as a kind debugging thing |
# |
Apr 19th 2017, 15:41 |
Neon1024 |
..and because jsonapi.org says not to |
# |
Apr 19th 2017, 15:41 |
crazycoder |
ok |
# |
Apr 19th 2017, 15:41 |
crazycoder |
oh right..pardon |
# |
Apr 19th 2017, 15:41 |
Neon1024 |
Because I was told not to use the .json extension |
# |
Apr 19th 2017, 15:41 |
crazycoder |
so i can set it on the renderer in that case (for errors) |
# |
Apr 19th 2017, 15:41 |
crazycoder |
Neon1024, but i do not get one point...why did you add a middleware to set the application/json... imean... if the extension is json it is obviosuly json no? (globally i mean) |
# |
Apr 19th 2017, 15:40 |
crazycoder |
:D |
# |
Apr 19th 2017, 15:40 |
crazycoder |
Neon1024, i am using it too |
# |
Apr 19th 2017, 15:39 |
admad |
They are a bunch of slackers |
# |
Apr 19th 2017, 15:39 |
Neon1024 |
I say ‘we’ I mean the team building it :p |
# |
Apr 19th 2017, 15:38 |
Neon1024 |
Hopefully some more people can try it too and we can get it to a 1.0 release |
# |
Apr 19th 2017, 15:38 |
Neon1024 |
So I can bin requests to my api if they don’t authenticate, without even leaving the middleware stack! :D |
# |
Apr 19th 2017, 15:38 |
Neon1024 |
I’ve also implemented the cakephp/authentication middleware in a branch |
# |
Apr 19th 2017, 15:37 |
Neon1024 |
Everything. You don’t get a choice:p |
# |
Apr 19th 2017, 15:37 |
Neon1024 |
As everything on my /api prefix will be json |
# |
Apr 19th 2017, 15:37 |
Neon1024 |
Well I do that in my middleware |
# |
Apr 19th 2017, 15:35 |
crazycoder |
oh better i set application/json |
# |
Apr 19th 2017, 15:35 |
crazycoder |
right ? |
# |
Apr 19th 2017, 15:35 |
crazycoder |
Neon1024, yes i should check if json...if yes i will skip that line |
# |
Apr 19th 2017, 15:35 |
Neon1024 |
Well there you are! |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
https://gist.github.com/anonymous/f23de065af63b1388b64bd8332bdf031#file-gistfile1-txt-L29 |
# |
Apr 19th 2017, 15:34 |
crazycoder |
Neon1024, https://gist.github.com/anonymous/f23de065af63b1388b64bd8332bdf031 |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
Perhaps you renderer is always assuming html |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
Then perhaps that could be why |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
As I think it’s supposed to pick a layout and template to match the extension |
# |
Apr 19th 2017, 15:34 |
crazycoder |
i am using a custom renderer ( i do not remember the reason ) :D |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
It’s the _outputMessage() method which confused me |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
Then changed the array data to match the json I wanted |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
if ($this->controller->request->is('json') andand strpos($this->controller->request->url, "api/v4") !== false) { |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
In the render() method I jsut added |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
I ended up copying it and just changing it a little to suit my needs |
# |
Apr 19th 2017, 15:32 |
Neon1024 |
I found the code in the ExceptionRenderer hard to follow |
# |
Apr 19th 2017, 15:32 |
crazycoder |
Neon1024, yes |
# |
Apr 19th 2017, 15:32 |
Neon1024 |
Hm, then perhaps it’s not hitting the controller action. Maybe the exception renderer doesn’t care about the headers and responds as html anyway |
# |
Apr 19th 2017, 15:32 |
crazycoder |
Neon1024, ^ |
# |
Apr 19th 2017, 15:32 |
crazycoder |
Neon1024, ? |
# |
Apr 19th 2017, 15:32 |
crazycoder |
no for not existant actions |
# |
Apr 19th 2017, 15:31 |
Neon1024 |
^ For your incorrect url I mean |
# |
Apr 19th 2017, 15:31 |
Neon1024 |
crazycoder: So if you use postman, and send a Content-Type: application/json header do you get a json error back? |
# |
Apr 19th 2017, 15:31 |
admad |
Erik: missing use statement |