$body = file_get_contents('php://input');
$incoming_data = json_decode($body, true);
switch($api_method) {
    case"connect":
        // Check user login
        if ($incoming_data['custom']['login'] == "bad_user") {
            ubnormalResponse(403);
        }
        // POST /connect query to WCS default RoomApp
        $response_data = json_decode(postToRoomApp($api_method, $body), true);
    break;
    default:
        // POST any query to WCS default RoomApp
        $response_data = json_decode(postToRoomApp($api_method, $body), true);
    break;
}
header('HTTP/1.1 200 OK', true, 200);
header('Content-Type: application/json');
echo json_encode($response_data);
// Passing query to WCS default RoomApp
function postToRoomApp($method, $data_string) {
    // Here should be your WSC RoomApp address
    $wcs_url="http://wcs:8081/apps/RoomApp/" . $method;
    $response="";
    if( $curl = curl_init() ) {
        curl_setopt($curl, CURLOPT_URL, $wcs_url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json',                                                                           
                               'Content-Length: ' . strlen($data_string)));  
        $response = curl_exec($curl);
        $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        if($http_code != 200) {
            ubnormalResponse($http_code);
        }
        error_log($response);
        curl_close($curl);
    }
    return($response);
}
function ubnormalResponse($code) {
    if ($code == 403) {
        header('HTTP/1.1 403 Forbidden', true, $code);
    } else {
        header(':', true, $code);
    }
    die();
}