<commit_before><?php
/**
 * File for HTTP Application class
 */

namespace Cayman\Application;

use Cayman\Application;
use Cayman\Exception;
use Cayman\Input;
use Cayman\Output;

/**
 * Class for HTTP Application
 * 
 */
class HttpApplication extends Application
{
    
    /**
     * Load input
     * @param array $serverData
     * @param array $inputData
     * @return Input
     */
    function loadInput(array $serverData = [], array $inputData = [])
    {
        $input = new Input();
        $input->setData($inputData);
        
        $api_prefix = $this->getSettings()->application->api_prefix ?: '';
        
        $method  = strtolower($serverData['REQUEST_METHOD']);// e.g. 'GET'
        $uri     = strtolower($serverData['REQUEST_URI']);   // e.g. '/api/v1/account/user/search'
        if ($uri == '/') {
            $uri = '/index/search';
        }
        $uri = str_replace($api_prefix, '', $uri, $count = 1);
        
        do {
            // custom /module/service/action/UUID
            if ($matches   = $this->matchModuleServiceActionUuid($uri)){
                $command   = $matches['module'] . '/' . $matches['service'];
                $action    = $matches['action'];
                $contextId = $matches['uuid'];
                break;
            }
            // custom /module/service/action/INTEGER
            if ($matches   = $this->matchModuleServiceActionInt($uri)){
                $command   = $matches['module'] . '/' . $matches['service'];
                $action    = $matches['action'];
                $contextId = $matches['integer'];
                break;
            }
            // custom /service/action
            if ($matches   = $this->matchServiceAction($uri)){
                $command   = $matches['service'];
                $action    = $matches['action'];
                break;
            }
            
            switch ($method) {
                case 'get':
                    // get /module/service/UUID retrieve
                    if ($matches   = $this->matchModuleServiceUuid($uri)){
                        $command   = $matches['module'] . '/' . $matches['service'];
                        $action    = 'retrieve';
                        $contextId = $matches['uuid'];
                        break;
                    }
                    // get /module/service/INT retrieve
                    if ($matches   = $this->matchModuleServiceInt($uri)){
                        $command   = $matches['module'] . '/' . $matches['service'];
                        $action    = 'retrieve';
                        $contextId = $matches['integer'];
                        break;
                    }
                    // get custom /module/service/action
                    if ($matches = $this->matchModuleServiceAction($uri)){
                        $command = $matches['module'] . '/' . $matches['service'];
                        $action  = $matches['action'];
                        break;
                    }
                    // get custom /module/service search
                    if ($matches = $this->matchModuleService($uri)){
                        $command = $matches['module'] . '/' . $matches['service'];
                        $action  = 'search';
                        break;
                    }
                    throw new Exception('Invalid get request');
                case 'post':
                    // post custom /module/service/action
                    if ($matches = $this->matchModuleServiceAction($uri)){
                        $command = $matches['module'] . '/' . $matches['service'];
                        $action  = $matches['action'];
                        break;
                    }
                    // post /module/service create
                    if ($matches = $this->matchModuleService($uri)){
                        $command = $matches['module'] . '/' . $matches['service'];
                        $action  = 'create';<commit_msg>default service action is index<commit_after><?php
/**
 * File for HTTP Application class
 */

namespace Cayman\Application;

use Cayman\Application;
use Cayman\Exception;
use Cayman\Input;
use Cayman\Output;

/**
 * Class for HTTP Application
 * 
 */
class HttpApplication extends Application
{
    
    /**
     * Load input
     * @param array $serverData
     * @param array $inputData
     * @return Input
     */
    function loadInput(array $serverData = [], array $inputData = [])
    {
        $input = new Input();
        $input->setData($inputData);
        
        $api_prefix = $this->getSettings()->application->api_prefix ?: '';
        
        $method  = strtolower($serverData['REQUEST_METHOD']);// e.g. 'GET'
        $uri     = strtolower($serverData['REQUEST_URI']);   // e.g. '/api/v1/account/user/index'
        if ($uri == '/') {
            $uri = '/index/index';
        }
        $uri = str_replace($api_prefix, '', $uri, $count = 1);
        
        do {
            // custom /module/service/action/UUID
            if ($matches   = $this->matchModuleServiceActionUuid($uri)){
                $command   = $matches['module'] . '/' . $matches['service'];
                $action    = $matches['action'];
                $contextId = $matches['uuid'];
                break;
            }
            // custom /module/service/action/INTEGER
            if ($matches   = $this->matchModuleServiceActionInt($uri)){
                $command   = $matches['module'] . '/' . $matches['service'];
                $action    = $matches['action'];
                $contextId = $matches['integer'];
                break;
            }
            // custom /service/action
            if ($matches   = $this->matchServiceAction($uri)){
                $command   = $matches['service'];
                $action    = $matches['action'];
                break;
            }
            
            switch ($method) {
                case 'get':
                    // get /module/service/UUID retrieve
                    if ($matches   = $this->matchModuleServiceUuid($uri)){
                        $command   = $matches['module'] . '/' . $matches['service'];
                        $action    = 'retrieve';
                        $contextId = $matches['uuid'];
                        break;
                    }
                    // get /module/service/INT retrieve
                    if ($matches   = $this->matchModuleServiceInt($uri)){
                        $command   = $matches['module'] . '/' . $matches['service'];
                        $action    = 'retrieve';
                        $contextId = $matches['integer'];
                        break;
                    }
                    // get custom /module/service/action
                    if ($matches = $this->matchModuleServiceAction($uri)){
                        $command = $matches['module'] . '/' . $matches['service'];
                        $action  = $matches['action'];
                        break;
                    }
                    // get custom /module/service index
                    if ($matches = $this->matchModuleService($uri)){
                        $command = $matches['module'] . '/' . $matches['service'];
                        $action  = 'index';
                        break;
                    }
                    throw new Exception('Invalid get request');
                case 'post':
                    // post custom /module/service/action
                    if ($matches = $this->matchModuleServiceAction($uri)){
                        $command = $matches['module'] . '/' . $matches['service'];
                        $action  = $matches['action'];
                        break;
                    }
                    // post /module/service create
                    if ($matches = $this->matchModuleService($uri)){
                        $command = $matches['module'] . '/' . $matches['service'];
                        $action  = 'create';
{'fraction_non_alphanumeric': 0.14253563390847712, 'fraction_numerical': 0.0005001250312578145, 'mean_word_length': 1.2615210630477807, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3942831', 'n_tokens_mistral': 1975, 'n_tokens_neox': 1866, 'n_words': 375}