diff --git a/php/web/index.php b/php/web/index.php index 28209a7..e930f20 100644 --- a/php/web/index.php +++ b/php/web/index.php @@ -29,18 +29,8 @@ function payload() { } else { return $input; } - case 'application/x-www-form-urlencoded': - if (!isset($_POST)) { - throw new InvalidPayloadException('_POST undefined'); - } - - if (!isset($_POST['payload'])) { - throw new InvalidPayloadException('payload not set in _POST'); - } - - return $_POST['payload']; default: - throw new InvalidPayloadException('Unsupported content type: ' . $_SERVER['HTTP_CONTENT_TYPE']); + throw new InvalidPayloadException('Unsupported content type: ' . $_SERVER['CONTENT_TYPE']); } } @@ -143,11 +133,13 @@ try { echo "ok"; } catch (DumpableException $e) { - header($_SERVER["SERVER_PROTOCOL"]." 400 Eh", true, 400); + trigger_error(print_r($e, true), E_USER_WARNING); + header("HTTP/1.1 400 Eh", true, 400); var_dump($e); echo ob_get_clean(); } catch (\Exception $e) { - header($_SERVER["SERVER_PROTOCOL"]." 400 Meh", true, 400); + trigger_error(print_r($e, true), E_USER_WARNING); + header("HTTP/1.1 400 Meh", true, 400); var_dump(get_class($e)); echo ob_get_clean(); } \ No newline at end of file diff --git a/php/web/next.php b/php/web/next.php deleted file mode 100644 index e930f20..0000000 --- a/php/web/next.php +++ /dev/null @@ -1,145 +0,0 @@ -repository)) { - throw new\ExecutionFailureException('Dataset does not have a repository'); - } - - if (!isset($input->repository->full_name)) { - throw new ExecutionFailureException('Dataset repository does not have a name'); - } - - $name = strtolower($input->repository->full_name); - $eventtype = event_type(); - - $connection = rabbitmq_conn(); - $channel = $connection->channel(); - - $dec = $channel->exchange_declare('github-events', 'topic', false, true, false); - - $message = new AMQPMessage(json_encode($input), - array( - 'content_type' => 'application/json', - 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT, - )); - - $routing_key = "$eventtype.$name"; - $rec = $channel->basic_publish($message, 'github-events', $routing_key); - - echo "ok"; -} catch (DumpableException $e) { - trigger_error(print_r($e, true), E_USER_WARNING); - header("HTTP/1.1 400 Eh", true, 400); - var_dump($e); - echo ob_get_clean(); -} catch (\Exception $e) { - trigger_error(print_r($e, true), E_USER_WARNING); - header("HTTP/1.1 400 Meh", true, 400); - var_dump(get_class($e)); - echo ob_get_clean(); -} \ No newline at end of file