How to write routing if already used any keyboard - codeigniter

Hi i used the routing for search like
$route['test-degrees/(:any)/(:num)/(:any)']='test/all_degrees/$1/$2/$3';
and i need to add new degree like
$route['test-degrees/(:any)/(:num)/(:add-degree-record)']="test-degrees/(:any)/(:num)/adddegreerecord";
but its does not call the adddegreerecord method. call the all_degree method

Related

Calling a controller/action through query parameters

Is it possible to call a controller and action directly by using query parameters in Laravel? I see some frameworks allow /index.php?_controller=X&_action=Y, or Yii allows /index.php?r=X/Y. I was wondering if something similar was possible in Laravel/Symfony.
symfony
The query string of a URL is not considered when matching routes. In this example, URLs like /blog?foo=bar and /blog?foo=bar&bar=foo will also match the blog_list route.
https://symfony.com/doc/6.0/routing.html
laravel afaik doesnt support that either
you are obviously free to just forward yourself
e.g. write one router that forwards to other controllers
symfony https://symfony.com/doc/6.1/controller/forwarding.html

Custom child commands for UI elements

We're currently using Select2 for all our <select> elements and for obvious reasons cy.get("#element").select("foo") won't work. As per the docs we've created our own custom command cy.get("#element").select2("foo") which just wraps a number of steps to select "foo".
This works well when trying to select a value but we'd like to avoid adding custom commands for clear(), value(), etc.
We'd also like to avoid using the Select2 API because this would require someone to understand that API as opposed to just working in the Cypress API.
We'd like to create something a bit more flexible by instead having a Cypress friendly object. Something that would look like this:
cy.get("#element").select2().as("select2");
cy.get("#select2").select("foo");
cy.get("#select2").should("be.equal", "foo");
cy.get("#select2").clear();
Is it possible to create a child-command that returns an object that can then override these built in commands?
We're unable to return our custom object from our custom command without first cy.wraping it which defeats the purpose.

path param in URL in GO without any web framework

While developing a REST api in Go, how can we use path params? meaning to say what will be the format of the URI?
http://localhost:8765/myapp/{param1}/entries/{param2}
I tried using something like this to create the route but the handler function is not getting invoked.
Please note that, i intent to use only the net/http package , not any other web framework like gorilla mux.
What I tend to do is nested handlers. "/" is handled by the root handler. It pops the first part of the path, assigns the rest back to req.URL.Path (effectively acting like StripPrefix), determines which handler handles routes by that prefix (if any), then chains the appropriate handler. If that handler needs to parse an ID out of the path, it can, by the same mechansim - pop the first part of the path, parse it as necessary, then act.
This not only has no external dependencies, but it is faster than any router could ever be, because the routing is hard-coded rather than dynamic. Unless routing changes at runtime (which would be pretty unusual), there is no need for routing to be handled dynamically.
Well this is why people use frameworks like gin-gonic because this is not easy to do this in the net/http package IIUC.
Otherwise, you would need to strings.Split(r.URL.Path, "/") and work from those elements.
With net/http the following would trigger when calling localhost:8080/myapp/foo/entries/bar
http.HandleFunc("/myapp/", yourHandlerFunction)
Then inside yourHandlerFunction, manually parse r.URL.Path to find foo and bar.
Note that if you don't add a trailing / it won't work. The following would only trigger when calling localhost:8080/myapp:
http.HandleFunc("/myapp", yourHandlerFunction)

Asp.Net Web Api - Change parameter name

In my team we have coding rule that requires that every function's parameter starts with prefix, e.g. *p_someParam*.
With Web Api if we want to request a GET function that takes two parameters, we should add those parameters like "...?p_firstParam=value1&p_secondParam=value2".
Is there some way to use in requests more user-friendly names, like someParam without prefix, that will automatically map to parameters in controller's action? Maybe there is some attribute to rename action parameters? I couldn't find any similar example.
Every clue is appreciated.
I think you looking for URL rewriting, in that you need to map the urls to config or programmatic
http://www.codeproject.com/Articles/2538/URL-Rewriting-with-ASP-NET nice article to follow, its in ASP.Net,

How to call an action inside another action in Yii?

I've a situation where i get some information from database and based on the data , i want to do/forward to some other controller & action.
How can i do this using Yii? Its like an ajax request..
If i can use the CController->forward() , then how can use the post values for actions?
I shall assume that the reason why redirect() didn't work for you was because you can't sent post variables with it. If that's the case, then let me show you how to overcome the lack of POST support in redirect(). You can use setState(). It creates variables that simulate POST variables. This is the code to store or set a variable:
Yii::app()->user->setState('var', 'value');
And, in order to trace the value you just code as follows:
Yii::app()->user->getState('param1');
It would equally work with forward, but I'm not sure why you want to use it instead of redirect().

Resources