title: How to Remove/Register Suffix on Laravel Route?
body: <p><strong>EDIT: See below for my current problem. The top portion is a previous issue that I've solved but is somewhat related</strong></p>
  
  <p>I need to modify the input values passed to my controller before it actually gets there. I am building a web app that I want to be able to support multiple request input types (JSON and XML initially). I want to be able to catch the input BEFORE it goes to my restful controller, and modify it into an appropriate StdClass object. </p>
  
  <p>I can't, for the life of me, figure out how to intercept and modify that input. Help?</p>
  
  <p>For example, I'd like to be able to have filters like this:</p>
  
  <pre><code>Route::filter('json', function()
  {
      //modify input here into common PHP object format
  });
  
  Route::filter('xml', function()
  {
      //modify input here into common PHP object format
  });
  
  Route::filter('other', function()
  {
      //modify input here into common PHP object format
  });
  
  Route::when('*.json', 'json'); //Any route with '.json' appended uses json filter
  Route::when('*.xml', 'xml'); //Any route with '.json' appended uses json filter
  Route::when('*.other', 'other'); //Any route with '.json' appended uses json filter
  </code></pre>
  
  <p>Right now I'm simply doing a <code>Input::isJson()</code> check in my controller function, followed by the code below - note that this is a bit of a simplification of my code.</p>
  
  <pre><code>$data = Input::all();
  $objs = array();
  foreach($data as $key =&gt; $content)
  {
      $objs[$key] = json_decode($content);
  }
  </code></pre>
  
  <p><strong>EDIT: I've actually solved this</strong>, but have another issue now. Here's how I solved it:</p>
  
  <pre><code>Route::filter('json', function()
  {
      $new_input = array();
      if (Input::isJson())
      {
          foreach(Input::all() as $key =&gt; $content)
          {
              //Do any input modification needed here
              //Save it in $new_input
          }
          Input::replace($new_input);
      }
      else
      {
          return "Input provided was not JSON";
      }
  });
  
  Route::when('*.json', 'json'); //Any route with '.json' appended uses json filter
  </code></pre>
  
  <p>The issue I have now is this: The path that the Router attempts to go to after the filter, contains <code>.json</code> from the input URI. The only option I've seen for solving this is to replace <code>Input::replace($new_input)</code> with</p>
  
  <pre><code>$new_path = str_replace('.json', '', Request::path());
  Redirect::to($new_path)-&gt;withInput($new_input);
  </code></pre>
  
  <p>This however leads to 2 issues. Firstly I can't get it to redirect with a <code>POST</code> request - it's always a <code>GET</code> request. Second, the data being passed in is being flashed to the session - I'd rather have it available via the <code>Input</code> class as it would be with <code>Input::replace()</code>.</p>
  
  <p>Any suggestions on how to solve this?</p>