-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
API::route() #12
Comments
You mean route names?
|
Yeah, access the api route with the name for internal requests
|
Will look into it.
|
Implemented. 😄 |
Hey Jason, latest push does not find the routes by name? URL::route('bla')?? |
Any other details you can supply would be great. I'm about to head off for
|
Well, basically after you pushed that fix 9 days ago i think it was working, although this is kind of on the side project here... but after defining a route with a
then calling
it throws an error in the URL generator saying that the route is not defined. |
Also, it seems as if when running:
that the urls are not showing up as well. |
Is this to do with the API? What I pushed allows you to run API::route so
|
That’s what I’m saying… it is throwing an error now when I try to create a URL the route name ( its for a javascript url in a blade file ). I don’t think I did anything to ruin this functionality, but Ill check. If your saying that the routes dont get registered as they normally do, I guess I can understand that... but it kinda screws up my workflow with the way I use various urls in the application. I hate defining paths, because I tend to change them as I develop. On May 5, 2014, at 10:06 AM, Jason Lewis notifications@github.com wrote:
|
You probably can't use URL::route because these routes are not registered
|
Cool man thanks a bunch. For what it's worth, i really like this package... Have a great night man. |
If you dont think this is a good idea, scratch what I just asked for... I just think it makes sense that the routes be registered that way. Cleaner while your generating urls in your app with names and array params. |
Jason, so i may not be doing something right, but im trying to access a route with :
and its not working. Im getting a Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException But if I access the url in the browser, it works I traced it and it seems like it finds the correct url by the route name right before queueRequest() is called. |
Dont know what's really going on but it looks like you are comparing the current request to see if it's an API route in
it is using the route in context... so if your hitting:
its using /foo instead of bar. |
Can you paste a sample of your routes? I have a named API route and using |
Well it seems to be unrelated to route() in particular, because im getting
|
Have you updated to the latest version recently? It was bumped to |
for the record... this returns me to the api route. - complete setup here
|
Well I'm stumped. I copied your code exactly as you've pasted it and it works fine. Can access it using |
Hey, I figured it out! It has to do with the prefix stuff in the
if you set another prefix down the line, it overrides the previous prefix. I did a trace on it and the prefix was absolutely the culprit. So, usually I group things and use the prefix for a lot of my routes, to keep things clean, and in this case, I see that every API route grouping needs to follow 1 prefix pattern or it breaks. Try adding this next snippet underneath the previous code, simulating just loading in another api grouping somewhere in your app -
|
Yeah an API should use a single prefix (which is why there's a configuration option for it). You can still nest |
yeah i totally get that now… I’m sure I can update things the right way now that I know why it was failing. I wasted a bit of time on that one! :) Thanks as always man, your great. On May 9, 2014, at 7:31 AM, Jason Lewis notifications@github.com wrote:
|
Is it possible to generate a URL for a dingo/api named route? I've named an API route When trying to generate the named route's URL via Laravel's
Any ideas? |
Instead of using the existing Laravel router we will use a new instance. This should prevent the APIs internal dispatcher from overriding the current route on the actual Laravel router instance. There does not seem to be any need for the router instance that is injected into the adapter to be the actual Laravel router, as the adapter just needs an instance to dispatch the API-only routes.
I'm confused as to how I'm supposed to access these routes natively, this provider uses its own router which doesn't allow me to use other packages that makes routing accessible in javascript or with the simple route() helper function... What a pain in the arse ;( |
Hey Jason, any chance you wanted to build in support for the route() call vs clunky url patterns? :) I think it would be fantastic to do that, so in your internal API requests, they could be so clean.
The text was updated successfully, but these errors were encountered: