# get and post in one action do different stuff - is it OK?

I'm using Kohana's routing with the route being defined as domain/controller/action. To demonstrate my question let's consider sign-in flow. Currently, if I want to sign-in user I need to return form first and then proceed with data sent by user. Do I need to have two actions, each for the corresponding flow (returning flow and proceeding with user data), or it can be done with one action by differentiating between POST and GET requests? I have one action now which returns form template if GET request is made and proceeds with signing in if POST request is made, but I question that architecture. Here is the sample of code:

public function action_signUp() {
if (HTTP_Request::POST == $this->request->method()) { //proceed with user sent data } else if (HTTP_Request::GET ==$this->request->method()) {
//return form template
}
}

• Can you not route get and post requests to different actions? – Cameron Martin Mar 19 '14 at 11:53
• Sure I can, I just want to know the best practice :) – Max Koretskyi aka Wizard Mar 19 '14 at 12:14
• Is there any difference in the controller logic for each branch (except rendering different content)? It would be helpful to post the code inside the conditionals. – Cameron Martin Mar 19 '14 at 12:55
• The difference is that GET branch simply renders log-in view, while the POST branch logs in user and returns redirect – Max Koretskyi aka Wizard Mar 19 '14 at 13:41