Exemple #1
0
$r->addMap("GET", "/Foo/hello", "Foobar::foo");
$r->addMap("POST", "/Foo/hello", "Foobar::foo");
$r->addMap("GET", "/Foo/hello/[\\w]*", "Foobar::foo");
$r->addMap("GET", "/Foo/restricted/basic", "Foobar::auth");
$r->addMap("GET", "/Foo/restricted/digest", "Foobar::auth");
$r->addMap("GET", "/Foo/bench", "Foobar::bench");
$r->addMap("GET", "/Lambda", function ($rest) {
    $rest->getResponse()->setResponse("Hello Closure!");
    return $rest;
});
$r->addMap("GET", "/hello/:name", function ($rest) {
    $rest->getResponse()->setResponse("Hello, " . $rest->getRequest()->getParameter("name") . "!");
    return $rest;
});
if ($r->getQuery(2) == "restricted") {
    if ($r->getQuery(3) == "basic") {
        $r->getAuthenticator()->requireAuthentication(true);
        if ($r->getAuthenticator()->getUser() == "joe" && $r->getAuthenticator()->GetPassword() == "123") {
            $r->getAuthenticator()->setAuthenticated(true);
        }
    } else {
        if ($r->getQuery(3) == "digest") {
            $r->getAuthenticator()->forceDigest(true);
            $user = $r->getAuthenticator()->getUser();
            $pass = "******";
            $r->getAuthenticator()->validate($user, $pass);
        }
    }
}
echo $r->execute();
Exemple #2
0
$rest = new RestServer($_GET["q"]);
$ref = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "";
$ip = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : "";
$rest->addMap("GET", "/?", "WebController");
if (MM_Utils::isMemberMouseActive() && MM_MemberMouseService::hasPermission(MM_MemberMouseService::$FEATURE_API)) {
    $rest->addMap("GET", "/createMember", "MemberController::createMember");
    $rest->addMap("POST", "/createMember", "MemberController::createMember");
    $rest->addMap("GET", "/purchaseBundle", "MemberController::purchaseBundle");
    $rest->addMap("POST", "/purchaseBundle", "MemberController::purchaseBundle");
    $rest->addMap("GET", "/updateMember", "MemberController::updateMember");
    $rest->addMap("POST", "/updateMember", "MemberController::updateMember");
    $rest->addMap("GET", "/getMember", "MemberController::getMember");
    $rest->addMap("POST", "/getMember", "MemberController::getMember");
    // added as temporary end point for SamCart to use until our new API is released
    $rest->addMap("GET", "/addMember", "MemberController::addMember");
    $rest->addMap("POST", "/addMember", "MemberController::addMember");
    $rest->addMap("GET", "/addBundle", "MemberController::addBundle");
    $rest->addMap("POST", "/addBundle", "MemberController::addBundle");
    $rest->addMap("GET", "/removeBundle", "MemberController::removeBundle");
    $rest->addMap("POST", "/removeBundle", "MemberController::removeBundle");
    $rest->addMap("GET", "/getMembershipLevels", "MemberController::getMembershipLevels");
    $rest->addMap("POST", "/getMembershipLevels", "MemberController::getMembershipLevels");
    $rest->addMap("GET", "/getBundles", "MemberController::getBundles");
    $rest->addMap("POST", "/getBundles", "MemberController::getBundles");
}
$rest->addMap("GET", "/deployRelease", "ReleaseController::deployRelease");
$rest->addMap("POST", "/deployRelease", "ReleaseController::deployRelease");
$rest->addMap("GET", "/ping", "ReleaseController::ping");
$rest->addMap("POST", "/ping", "ReleaseController::ping");
echo $rest->execute();