Log message #4184471

# At Username Text
# Apr 24th 2019, 20:02 mrgrimpy I thank you very much for your time and answers
# Apr 24th 2019, 20:02 mrgrimpy I will try that implementation tomorrow
# Apr 24th 2019, 20:00 jeremyharris it reflects the truth the best - you don’t have a route for non-json exts there, so let the framework do what it does with a missing route exception
# Apr 24th 2019, 20:00 jeremyharris yeah that feels the best
# Apr 24th 2019, 20:00 jeremyharris there are a few layers you can handle it at really
# Apr 24th 2019, 19:59 mrgrimpy The extending the route class looks like the cleanest option
# Apr 24th 2019, 19:59 mrgrimpy Indeed there are but I was sure there was a "proper" way
# Apr 24th 2019, 19:58 mrgrimpy I tought about checking url in controller and throwing a 404 if not .json but it felt dirty
# Apr 24th 2019, 19:58 jeremyharris :)
# 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']);