/**
  * Test ETag with invalid type
  */
 public function testETagWithInvalidType()
 {
     $this->setExpectedException('\\InvalidArgumentException');
     \Slim\Environment::mock(array('SCRIPT_NAME' => '/foo', 'PATH_INFO' => '/bar', 'IF_NONE_MATCH' => '"abc1234"'));
     $s = new \Slim\Slim();
     $s->get('/bar', function () use($s) {
         $s->etag('123', 'foo');
     });
     $s->call();
 }
Example #2
0
<?php

require 'vendor/autoload.php';
// http://docs.slimframework.com/
$app = new \Slim\Slim();
$app->config('debug', true);
$app->config('log.enable', true);
$app->config('mode', "development");
$app->config('templates.path', "./tpl");
// $appVersion =  md5("v2.3.1");
// main page
$app->get('/', function () use($app, $appVersion) {
    $app->etag($appVersion);
    $app->render("front.php");
});
// json services
$app->get('/json/:json', function ($json) use($app, $appVersion) {
    if ($json == "feeds") {
        $app->etag($appVersion);
        $app->render($json . ".php");
    } else {
        $app->notFound();
    }
});
$app->run();
Example #3
0
    }
    $response = $session->getUser()->getTestResult();
    Helpers::sendJson($response);
});
$app->delete('/result', function () use($session) {
    if (!checkAuth()) {
        return;
    }
    $status = $session->getUser()->resetTestResult();
    Helpers::sendJson(array('status' => $status));
});
$app->get('/groups', function () use($app) {
    if (!checkAdminAuth()) {
        return;
    }
    $app->etag('groups');
    $app->expires('+15 minutes');
    Helpers::sendJson(AdminHelpers::getGroups());
});
$app->get('/admin/results', function () use($app) {
    if (!checkAdminAuth()) {
        return;
    }
    $filters = $app->request()->get();
    $response = AdminHelpers::getResults($filters);
    Helpers::sendJson($response);
});
$app->get('/admin/result/:studentId', function ($studentId) {
    if (!checkAdminAuth()) {
        return;
    }
Example #4
-1
// Define our Namespace
namespace Bloom\Schedule\API;

use Bloom\Schedule\API\Model\Booking;
use Bloom\Schedule\API\Model\Statistics;
// Auto-load the classes via Composer's PSR-4 autoloader
require 'vendor/autoload.php';
// Configure log writer
$config['app']['log.writer'] = new \Flynsarmy\SlimMonolog\Log\MonologWriter(array('handlers' => array(new \Monolog\Handler\StreamHandler('data/logs/' . date('Y-m-d') . '.log'))));
// Start Slim
$app = new \Slim\Slim($config['app']);
// Start log writer
$log = $app->getLog();
// Set response headers
$app->response->headers->set('Content-Type', 'application/json;charset=utf-8');
$app->etag(md5(time()));
// Define path & URL
$req = $app->request;
define('ROOT', $req->getPath());
define('URL', $req->getUrl());
// Bookings
$app->group('/booking', function () use($app, $log) {
    // Returns the details of all current and future bookings
    $app->get("/all", function () use($app, $log) {
        Booking::all($app);
    });
    // Returns the details of the next bookings for room number of :room
    $app->get("/next/:room", function ($room) use($app, $log) {
        Booking::next($app, $room);
    });
    // Returns the details of the booking an id of :id