Changeset b858e6f for src/webservice/htdocs/index.php
- Timestamp:
- Aug 28, 2015, 3:59:07 PM (11 years ago)
- Branches:
- master
- Children:
- 552da81
- Parents:
- 1e37648
- File:
-
- 1 edited
-
src/webservice/htdocs/index.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/webservice/htdocs/index.php
r1e37648 rb858e6f 42 42 } 43 43 44 /** 45 * @brief Registers a new weather station 46 */ 47 function stationsRegister(){ 48 try{ 49 $app = \Slim\Slim::getInstance("siweather"); 50 $body = $app->request->getBody(); 51 $json = json_decode($body); 52 53 $location = new IpGeoLocator($app->request->getIp()); 54 if($location->city() != $json["city"]){ 55 return json_encode(["result" => "unprovenlocation", "message" => "You send "]); 56 } 57 58 $app->response()->header("Content-Type", "application/json"); 59 echo json_encode($json); 60 } 61 catch(Exception $exception){ 62 error_log("Caught exception handling request stationsRegister: ". $exception->getMessage()); 63 $app->response()->status(400); 64 $app->response()->header("X-Status-Reason", $exception->getMessage()); 65 } 66 } 67 44 68 $app = new \Slim\Slim 45 69 ( … … 49 73 ) 50 74 ); 51 $app->setName(" SiWeather Webservice");75 $app->setName("siweather"); 52 76 53 77 // Only invoked if mode is "production" … … 84 108 85 109 $app->get("/stations", "stations"); 86 $app->get("/stations/:uuid", function ($uuid){ 87 echo "stations 123"; 88 }); 89 90 110 $app->post("/stations/register", "stationsRegister"); 91 111 92 112 $app->run();
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/siweather/chrome/site/your_project_logo.png)