source: src/webapp/webservice/inc/GnuBoat/Webservice.php@ b76295a

debian/bullseye
Last change on this file since b76295a was 0662b2d, checked in by Joachim Langenbach <joachim.langenbach@…>, 9 years ago

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

  • Property mode set to 100644
File size: 1.7 KB
Line 
1<?php
2/*
3 Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19namespace GnuBoat;
20
21require_once(__DIR__ ."/../autoloader.php");
22
23class WebService
24{
25 function __construct($debug)
26 {
27 $this->_requests = array();
28 $this->_requests["data"] = "GnuBoat\ServiceData";
29 $this->_requests["shutdown"] = "GnuBoat\ServiceShutdown";
30 $this->_requests["logfiles"] = "GnuBoat\ServiceLogFiles";
31 $this->_requests["map"] = "GnuBoat\ServiceMap";
32 $this->_requests["replay"] = "GnuBoat\ServiceReplay";
33
34 $this->_debug = $debug;
35 }
36
37 public function process()
38 {
39 $request = array_keys($this->_requests)[0];
40 if(is_array($_GET) && array_key_exists("request", $_GET)){
41 $request = $_GET["request"];
42 }
43
44 if(!array_key_exists($request, $this->_requests)){
45 return Service::errorStatic("Request ". $request ." not implemented", $this->_debug);
46 }
47
48 call_user_func(array(new $this->_requests[$request], "processRequest"), $this->_debug);
49 }
50
51 private $_requests;
52 private $_debug;
53}
54
55?>
Note: See TracBrowser for help on using the repository browser.