Ignore:
Timestamp:
Aug 28, 2015, 3:29:08 PM (11 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
master
Children:
b858e6f
Parents:
851179e
Message:
  • Rewrites are now working
    • Setup is now accessable via Slim too
    • Added 404 template to Slim app
Location:
src/webservice/htdocs/SiWeather/Webservice
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/webservice/htdocs/SiWeather/Webservice/Setup.php

    r851179e r1e37648  
    306306       
    307307        public function apiCheckWithRewrite(&$errorMessage){
    308                 $apiVersion = $this->_webserviceConfig->getConfig("webserviceApiVersion");
    309                 if(!$apiVersion || empty($apiVersion)){
    310                         $errorMessage = _("Could not determine API version");
    311                         return false;
    312                 }
    313                
    314                 return $this->apiCheck($apiVersion ."/stations", $errorMessage);
     308                return $this->apiCheck("stations", $errorMessage);
    315309        }
    316310
    … …  
    326320       
    327321        private function apiCheck($url, &$errorMessage){
    328                 $baseUrl = $this->_webserviceConfig->getConfig("webserviceBaseUrl");
     322                $baseUrl = $this->_webserviceConfig->webserviceBaseUrl();
    329323                if(!$baseUrl || empty($baseUrl)){
    330324                        $errorMessage = _("No webservice base url given!");
    … …  
    332326                }
    333327
     328                # base_url needs to end with a /, otherwise the last element is chopped
    334329                $client = new \GuzzleHttp\Client
    335330                (
    … …  
    347342                $result = $response->getStatusCode();
    348343                if($result != 200){
    349                         $errorMessage = \Translator::swGettext("Got http error %s (%s)", $result, $response->getReasonPhrase());
     344                        $errorMessage = \Translator::swGettext("Got http error %s (%s) at url %s", $result, $response->getReasonPhrase(), $baseUrl ."/". $url);
    350345                        return false;
    351346                }
  • src/webservice/htdocs/SiWeather/Webservice/WebserviceConfig.php

    r851179e r1e37648  
    2424
    2525        function __construct(){
    26                 require(__DIR__ ."/../../config/config.php");
     26                require(__DIR__ ."/../../../config/config.php");
    2727                $this->_config = $config;
    2828                $this->loadAdditionalConfiguration();
    … …  
    3535        private function loadAdditionalConfiguration(){
    3636                $this->_config["dataDirectory"] = "data";
     37               
     38                require(__DIR__ ."/../../inc/internalconfig.php");
     39                foreach(array_keys($internalconfig) as $key){
     40                        if(array_key_exists($key, $this->_config)){
     41                                error_log("Internal config entry ". $key ." already exists --> Keeping existing value and discard internal config value");
     42                        }
     43                        else{
     44                                $this->_config[$key] = $internalconfig[$key];
     45                        }
     46                }
    3747        }
    3848
    … …  
    4757                        return $this->dataDirectory();
    4858                }
     59                if($key == "webserviceBaseUrl"){
     60//                      error_log("Use dataDirectory() function to access this value");
     61                        return $this->webserviceBaseUrl();
     62                }
    4963               
    5064                return $this->_config[$key];
    … …  
    5266
    5367        public function dataDirectory(){
    54                 return __DIR__ ."/../../". $this->_config["dataDirectory"];
     68                return __DIR__ ."/../../../". $this->_config["dataDirectory"];
     69        }
     70       
     71        public function webserviceBaseUrl(){
     72                $baseUrl = $this->_config["webserviceBaseUrl"];
     73                if(substr($baseUrl, strlen($baseUrl) - 1, 1) != "/"){
     74                        $baseUrl .= "/";
     75                }
     76                return $baseUrl;
    5577        }
    5678
Note: See TracChangeset for help on using the changeset viewer.