# |
Apr 24th 2019, 19:58 |
jeremyharris |
so many options |
# |
Apr 24th 2019, 19:58 |
jeremyharris |
finally, you could overwrite _getViewFileName in your AppView to catch the MissingTemplateException and throw your own (that sets status to 404) |
# |
Apr 24th 2019, 19:58 |
mrgrimpy |
Would probably work, I haven,t played with custom route classes to be honest |
# |
Apr 24th 2019, 19:58 |
jeremyharris |
that would work too I think |
# |
Apr 24th 2019, 19:57 |
jeremyharris |
can you extend that route class and check the ext in your new route class, returning false (no match) if it doesn’t have the json ext? |
# |
Apr 24th 2019, 19:57 |
mrgrimpy |
So if I do like $routes->connect('/niveaux2.json') I believe the plugin doesn't like the extension and throws 404 |
# |
Apr 24th 2019, 19:57 |
mrgrimpy |
My routes are built like this /language/rest |
# |
Apr 24th 2019, 19:57 |
mrgrimpy |
I believe it's because it doesn't play nicely with ADmad/I18n plugin |
# |
Apr 24th 2019, 19:56 |
mrgrimpy |
Ok so it gives me a 404: Controller class En could not be found. |
# |
Apr 24th 2019, 19:55 |
jeremyharris |
another solution would be to add a middleware that checks if the request is within your scope and catch the exception and change the status code there |
# |
Apr 24th 2019, 19:55 |
mrgrimpy |
sec |
# |
Apr 24th 2019, 19:55 |
mrgrimpy |
let me do it to be more specific |
# |
Apr 24th 2019, 19:55 |
mrgrimpy |
I did try but I get a different error |
# |
Apr 24th 2019, 19:55 |
jeremyharris |
I could be wrong, but I think what you would need to do is change your route to have the .json in the path so it only matches with that ext, that would throw a missing route exception instead which is a 404 |
# |
Apr 24th 2019, 19:54 |
mrgrimpy |
I'm on version 3.4.14 |
# |
Apr 24th 2019, 19:53 |
mrgrimpy |
Didn't read the code tough |
# |
Apr 24th 2019, 19:52 |
mrgrimpy |
I read the docs 2-3 times already but I could have missed the solution |
# |
Apr 24th 2019, 19:52 |
mrgrimpy |
Thank you very much |
# |
Apr 24th 2019, 19:52 |
jeremyharris |
ok lemme dig through the docs/code to see if I can find a solution for you |
# |
Apr 24th 2019, 19:51 |
mrgrimpy |
It logs Error: [Cake\View\Exception\MissingTemplateException] Template file "Ressources/niveaux2.ctp" is missing. |
# |
Apr 24th 2019, 19:51 |
mrgrimpy |
Yes a 500 |
# |
Apr 24th 2019, 19:51 |
mrgrimpy |
I tried earlier |
# |
Apr 24th 2019, 19:51 |
jeremyharris |
probably a 500? |
# |
Apr 24th 2019, 19:51 |
jeremyharris |
ok what do you get with debug off? |
# |
Apr 24th 2019, 19:51 |
mrgrimpy |
I would rather the application throw a 404 |
# |
Apr 24th 2019, 19:51 |
mrgrimpy |
With debug on I get Cake\View\Exception\MissingTemplateException |
# |
Apr 24th 2019, 19:51 |
mrgrimpy |
Hi, yes I unfortunately still haven't found a solution |
# |
Apr 24th 2019, 19:50 |
jeremyharris |
usually you should see the json version of the missing template exception (if debug) or the 404/500 (can’t remember) if debug is off |
# |
Apr 24th 2019, 19:50 |
jeremyharris |
@mrgrimpy if you’re still working on your issue, have you deleted the template for the normal view? |
# |
Apr 24th 2019, 19:39 |
mrgrimpy |
Hi this is Coddyx, just switched platform. |
# |
Apr 24th 2019, 17:50 |
Coddyx |
Anyone? |
# |
Apr 24th 2019, 17:38 |
Coddyx |
Here is my route (within '/' scope') $routes->connect('/niveaux2', ['controller' => 'Ressources', 'action' => 'niveaux2'], ['_name' => 'niveaux2', '_ext' => ['json'], 'routeClass' => 'ADmad/I18n.I18nRoute']); |
# |
Apr 24th 2019, 17:37 |
Coddyx |
Hi, I am working on a simple controller that spits out JSON and I was wondering how to set up routes to output JSON only? I tried many things but the application always try to respond to the URL without ".json" at the end instead of throwing a 404. |
# |
Apr 24th 2019, 17:21 |
asdfgh |
so do i must start from a smallint |
# |
Apr 24th 2019, 17:21 |
asdfgh |
ok i got it, it is used for bool too |
# |
Apr 24th 2019, 17:21 |
asdfgh |
i read that i can use number until 255 in a tinyint field, is wrong? |
# |
Apr 24th 2019, 17:20 |
admad |
*MySQL not myself :) |
# |
Apr 24th 2019, 17:20 |
admad |
Because tinyint(1) is used to emulate boolean in myself since it doesn't have actual boolean type |
# |
Apr 24th 2019, 17:20 |
dereuromark |
oh geeze |
# |
Apr 24th 2019, 17:18 |
asdfgh |
why should i use INT or something bigger thatn tinyint if the table is so small ? |
# |
Apr 24th 2019, 17:18 |
dereuromark |
even for 1 entry only |