may I ask what the reason is that in GENESIS
these POST routes are inside CONTROLLER() and not router() function.
do case
case AP_Method() == "GET"
AP_RPuts( View( "default" ) )
case AP_Method() == "POST"
do case
case cAction == "save"
? "post save"
Save()
case cRequest == "login"
Login()
endcase
endcase
Best regards,
Otto
- Code: Select all Expand view
function Controller( cRequest )
local aRequest
if ":" $ cRequest
aRequest = hb_aTokens( cRequest, ":" )
cRequest = aRequest[ 1 ]
cAction = If( Len( aRequest ) > 1, aRequest[ 2 ], "browse" )
cParam1 = If( Len( aRequest ) > 2, aRequest[ 3 ], "" )
cParam2 = If( Len( aRequest ) > 3, aRequest[ 4 ], "" )
nVal1 = Val( cParam1 )
nVal2 = Val( cParam2 )
endif
if cRequest == "logout"
AP_HeadersOutSet( "Set-Cookie", "genesis=" )
cRequest = "login"
cUserName = "guest"
else
if ! hb_HhasKey( GetCookies(), "genesis" )
cRequest = "login"
else
if cUserName != "guest"
if cRequest == "login"
cRequest = "home"
endif
else
cRequest = "login"
endif
endif
endif
hb_default( @cAction, "browse" )
if cAction $ "add,browse"
if nVal1 == 0
nVal1 = 20
endif
endif
cContent = If( Empty( cRequest ), "home",;
If( cRequest $ "login,logout,home,controllers,logs,menus,routes,database,users,settings,tasks,views,weblinks",;
cRequest, "home" ) )
do case
case AP_Method() == "GET"
AP_RPuts( View( "default" ) )
case AP_Method() == "POST"
do case
case cAction == "save"
? "post save"
Save()
case cRequest == "login"
Login()
endcase
endcase
return nil
//----------------------------------------------------------------------------//
function Router()
local cRoute := "home"
if GetContent() != "home"
if GetContent() == "login"
cRoute = "login"
else
if GetAction() == "edit"
cRoute = "edit"
elseif GetAction() == "exec"
cRoute = "exec"
else
cRoute = "browse"
endif
endif
endif
return View( cRoute )
//----------------------------------------------------------------------------//