source: src/webservice/htdocs/index.php@ 4b09d68

Last change on this file since 4b09d68 was d55ec21, checked in by Joachim Langenbach <joachim.langenbach@…>, 11 years ago
  • Improved testing execution of webservice related tests (they use the built in php webserver to create a test webservice instance)
  • Property mode set to 100644
File size: 2.1 KB
Line 
1<?php
2/*
3 Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 MA 02110-1301 USA.
19*/
20
21require(__DIR__ ."/inc/envsetup.php");
22
23$settings = new SiWeather\Webservice\WebserviceConfig();
24
25$app = new \Slim\Slim
26(
27 array
28 (
29 "mode" => $settings->getConfig("mode"),
30 )
31);
32$app->setName("siweather");
33
34// Only invoked if mode is "production"
35$app->configureMode('production', function () use ($app) {
36 $app->config(array(
37 "log.enable" => true,
38 "log.level" => \Slim\Log::WARN,
39 "debug" => false,
40 ));
41});
42// Only invoked if mode is "development"
43$app->configureMode('development', function () use ($app) {
44 $app->config(array(
45 "log.enable" => true,
46 "log.level" => \Slim\Log::DEBUG,
47 "debug" => true
48 ));
49});
50
51$app->notFound(function () use ($app) {
52 $html = "";
53 if($app->config("debug")){
54 ob_start();
55 phpinfo( INFO_VARIABLES ^ INFO_ENVIRONMENT );
56 $html = ob_get_contents();
57 ob_end_clean();
58 }
59 $app->render("404.php", array("dump" => $html));
60});
61
62$app->get("/setup", function () use ($app){
63 $app->render("setup.php");
64});
65$app->get("/stations", function () use ($app){
66 \SiWeather\Webservice\WebserviceApi::stations();
67});
68$app->post("/stations/register", function () use ($app){
69 \SiWeather\Webservice\WebserviceApi::stationsRegister();
70});
71
72$app->run();
73
74?>
Note: See TracBrowser for help on using the repository browser.