Welcome Guest, Not a member yet? Register   Sign In
when I set routes with add and post, It's not work
#1

(This post was last modified: 09-07-2021, 08:42 AM by asrahi.)

Hi!
I was setting $routes like this,
But it's not work
I expected, if I connect "test.com/board" then call Board:list
and I try to submit form POST in "test.com/board", as I know it's call BoardConfusedearch.

I was trying to modify my code to priority, as, and something else...
but it's not work too

filnaly I figure out, if Im trying to use "get" instead of "add", then It's work..  Huh
I couldn't understand well
plz tell me this problem

Thank you


PHP Code:
$routes->group('board',function($routes){
 
$routes->add('(:any)/view/(:num)''Board::read/$1/$2');
 
$routes->add('(:any)/read/(:num)''Board::read/$1/$2');
 
$routes->add('(:any)/read/(:num)/(:any)''Board::read/$1/$2/$3', ['as'=>'board_read']);

 
$routes->add('(:any)/write''Board::write/$1/$2');
 
$routes->add('(:any)/write/(:any)''Board::write/$1/$2', ['as'=>'board_write']);

 
$routes->add('(:any)/edit/(:num)''Board::edit/$1/$2');
 
$routes->add('(:any)/edit/(:num)/(:any)''Board::edit/$1/$2/$3', ['as'=>'board_edit']);

 
$routes->add('(:any)/closed''Board::block/$1');
 
$routes->add('(:any)/closed/(:any)''Board::block/$1', ['as'=>'board_block']);

 
$routes->add('(:any)/del/(:num)''Board::del/$1/$2', ['as'=>'board_del']);

 
$routes->post('(:any)/post''Board::post/$1', ['as'=>'board_post']);
 
$routes->post('(:any)/replyPost''Board::replyPost/$1', ['as'=>'board_reply']);

 
$routes->post('(:any)''Board::search/$1',['priority'=>1]); //예약조회 등등
 
$routes->add('(:any)''Board::list/$1',['as'=>'board_list''priority'=>10]); //리스트

});
$routes->addRedirect('board','/'); 

Reply
#2

(This post was last modified: 09-07-2021, 12:50 PM by ikesela.)

better use 'get' instead 'add' , so router know what to do, not guessing what to do using 'add'

* from CI documentation: it is recommended to always use the HTTP-verb-based routes
Reply
#3

Using `add` will make the route available across ALL verbs (get, post, etc). It is always better to specify the exact verb you want used so that there's no unintended actions happening when a different verb gets used. While there's a very small chance that could form a security issue, it does cause issues like you were just seeing, also.
Reply
#4

(This post was last modified: 09-09-2021, 10:11 AM by asrahi.)

(09-07-2021, 12:48 PM)ikesela Wrote: better use 'get' instead 'add' , so router know what to do, not guessing what to do using 'add'

* from CI documentation: it is recommended to always use the HTTP-verb-based routes

Thank you! I'll use 'get'
Actually I can't understand well documentation, bcz I can't speak english well ;(

(09-07-2021, 12:58 PM)kilishan Wrote: Using `add` will make the route available across ALL verbs (get, post, etc). It is always better to specify the exact verb you want used so that there's no unintended actions happening when a different verb gets used. While there's a very small chance that could form a security issue, it does cause issues like you were just seeing, also.

Thank you!
I wonder, why the 'post' (written explicitly) can't has priority? even I set attribute of priority
Reply
#5

If your using chrome or any new web browser most have a language translation built in now.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB