-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: How can I add a filter to certain groupted routes? #250
Comments
Try something like this: |
Hi, Trying the following code:
It never throws the test exception. If I remove the test route, or simply call /api/ endpoint, it still doesn't run the exception callback. Any ideas? Also, with the following code:
I am having "Parse error: syntax error, unexpected 'if' (T_IF)". Am I overlooking something? My whole front controller looks like this:
|
Really? Its not working? I just linted your code and it doesn't seem to have any issues. I'm not sure what would be causing your parse error here. :/ |
outputs "hey" when I browse /api/test/moo. Oh, by the way, we use Laravel in our application. For the API, I forwarded /api/ calls with .htaccess to /public/api.php - api.php has: api/bootstrap/autoload has:
start.php has:
Not sure if this causes the problem. (which I doubt but it is really odd) |
Ooooo, I think I might know why. It might be because you're Try changing the path from |
@Rican7 Oh, yeah that was the case. It works properly now. Perhabs we should add it to documentation? |
Yea, we could, maybe a note of some kind. Its really just because of the way the server software (not Klein) was interpreting the path and redirecting you away from the trailing slash (most likely). Its out of Klein's hands there, but yea, I might make trailing slashes a bit less of a pain in a later version. |
Hey @Rican7 , is there any way to respond codes via filter function?
Is it doable in the current state of framework? Right now requests still go to the actual route, unless I do something like |
Oh, I did a ctrl f "abort" on the main page but couldn't find anything, so I assumed there is no such method. Abort will definitely solve my issue, thanks! |
@Rican7 Hey, sorry to disturb again. I cannot get it to work. My code looks like:
Do you know what could be the issue? I also tried $app->abort(), no luck. |
Hi,
I have a route group like:
I have different groups of API. Everything under
/api/something/
requires HTTP basic auth but it should only work for that instance. (e.gapi/somethingElse
doesn't require an auth.)Basically, something like:
I'm not sure how it is possible with klein. The check above affects application globally and every route group requires auth credentials.
Any ideas?
The text was updated successfully, but these errors were encountered: