Ookma-Kyi
07/18/2022, 7:57 PMcomponent extends="coldbox.system.EventHandler" {
// default Action
function index( event, rc, prc ){
event.setHTTPHeader( statusCode = 400 );
relocate(uri = "/");
}
// terms of service Action
function termsofservice( event, rc, prc ){
prc.pageTitle = "Terms of Service";
event.setView( "legal/termsofservice" );
}
...
}
I added a default action to redirect the user to the home page if they try to access the root of the uri example: localhost:8080/legal
and set the status code to 400 Bad Request
. Is this correct or should i be using a different status code?Robert Zehnder
07/19/2022, 1:12 PMRobert Zehnder
07/19/2022, 1:14 PMOokma-Kyi
07/19/2022, 1:33 PMRobert Zehnder
07/19/2022, 1:39 PMRobert Zehnder
07/19/2022, 1:40 PM// default Action
function index( event, rc, prc ){
relocate(uri = "/", statusCode = 400);
}
Robert Zehnder
07/19/2022, 1:42 PMOokma-Kyi
07/19/2022, 6:30 PMRobert Zehnder
07/19/2022, 6:32 PMRobert Zehnder
07/19/2022, 6:33 PMOokma-Kyi
07/19/2022, 6:33 PMRobert Zehnder
07/19/2022, 6:33 PMrelocate()
in the handler. I would not bother explicitly setting the response code, just do the redirectRobert Zehnder
07/19/2022, 6:34 PMOokma-Kyi
07/19/2022, 6:34 PMRobert Zehnder
07/19/2022, 6:35 PMOokma-Kyi
07/19/2022, 6:44 PMRobert Zehnder
07/19/2022, 6:45 PMbdw429s
07/20/2022, 7:36 PMbdw429s
07/20/2022, 7:37 PMbdw429s
07/20/2022, 7:38 PMbdw429s
07/20/2022, 7:38 PMbdw429s
07/20/2022, 7:39 PMindex()
function from your code, running the termsofservice() event inside of it if you want /legal
to show the same things as legal/termsOfService
!bdw429s
07/20/2022, 7:39 PMbdw429s
07/20/2022, 7:40 PMbdw429s
07/20/2022, 7:40 PMbdw429s
07/20/2022, 7:41 PM