Ignore:
Timestamp:
Aug 30, 2017, 2:45:37 PM (9 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
0.5, debian/bullseye, debian/jessie, master
Children:
a50c18f
Parents:
89c510f
Message:

Improved webservice class to use TrackItem in ServiceData.php and added some tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/webapp/webservice/inc/GnuBoat/Service.php

    r89c510f r0662b2d  
    4545        }
    4646       
    47         public static function error($message)
     47        public static function errorStatic($message, $additionalContent = array(), $debug)
    4848        {
    49                 Service::output(["error" => 1, "errormessage" => $message]);
     49                error_log($message);
     50                if($debug > 0)
     51                        print $message ."\n";
     52                $result = ["error" => 1, "errormessage" => $message];
     53                Service::outputStatic(array_merge($result, $additionalContent), $debug);
    5054        }
    5155       
    52         public static function output($content)
     56        public static function outputStatic($content, $debug)
    5357        {
    5458                header('Content-Type: application/json');
    55                 echo json_encode($content);
     59                if($debug > 0){
     60                        echo json_encode($content,  JSON_PRETTY_PRINT) ."\n";
     61                }
     62                else{
     63                        echo json_encode($content) ."\n";
     64                }
     65        }
     66       
     67        protected function error($message, $additionalContent = array())
     68        {
     69                Service::errorStatic($message, $additionalContent, $this->debug());
     70        }
     71       
     72        protected function output($content)
     73        {
     74                Service::outputStatic($content, $this->debug());
    5675        }
    5776
Note: See TracChangeset for help on using the changeset viewer.