aboutsummaryrefslogtreecommitdiff
path: root/src/CamilStaps/BotleaguesApi
diff options
context:
space:
mode:
authorCamil Staps2015-05-07 15:32:43 +0300
committerCamil Staps2015-05-07 15:32:43 +0300
commit714b36763f3d769c318ee2c43f8a7e7498fcd70b (patch)
tree69d475a146e31f9db789bae985ed3a05897f6374 /src/CamilStaps/BotleaguesApi
parentFixed last commit (diff)
LoginException; RedirectException
Diffstat (limited to 'src/CamilStaps/BotleaguesApi')
-rw-r--r--src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php9
-rw-r--r--src/CamilStaps/BotleaguesApi/Exception/LoginException.php5
-rw-r--r--src/CamilStaps/BotleaguesApi/Exception/RedirectException.php5
3 files changed, 19 insertions, 0 deletions
diff --git a/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php b/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
index 6351614..65fd737 100644
--- a/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
+++ b/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
@@ -5,6 +5,7 @@ use \Illuminate\Support\ServiceProvider;
use \Illuminate\Support\Facades\App;
use \Illuminate\Support\Facades\Config;
use \Dingo\Api\Facade\API;
+use Redirect;
use Response;
class BotleaguesApiServiceProvider extends ServiceProvider {
@@ -54,6 +55,14 @@ class BotleaguesApiServiceProvider extends ServiceProvider {
],
500);
});
+ API::error(function(Exception\LoginException $e) {
+ $response = Response::make("Please login", 401);
+ $response->header('WWW-Authenticate', 'Basic realm="Please login"');
+ return $response;
+ });
+ API::error(function(Exception\RedirectException $e) {
+ return Redirect::to($e->getMessage());
+ });
API::error(function(\Exception $e) {
return Response::make(
['error' => Config::get('app.debug') ? $e->getMessage() : "Internal error"],
diff --git a/src/CamilStaps/BotleaguesApi/Exception/LoginException.php b/src/CamilStaps/BotleaguesApi/Exception/LoginException.php
new file mode 100644
index 0000000..122d190
--- /dev/null
+++ b/src/CamilStaps/BotleaguesApi/Exception/LoginException.php
@@ -0,0 +1,5 @@
+<?php
+namespace CamilStaps\BotleaguesApi\Exception;
+
+class LoginException extends \Exception {
+} \ No newline at end of file
diff --git a/src/CamilStaps/BotleaguesApi/Exception/RedirectException.php b/src/CamilStaps/BotleaguesApi/Exception/RedirectException.php
new file mode 100644
index 0000000..12d64b5
--- /dev/null
+++ b/src/CamilStaps/BotleaguesApi/Exception/RedirectException.php
@@ -0,0 +1,5 @@
+<?php
+namespace CamilStaps\BotleaguesApi\Exception;
+
+class RedirectException extends \Exception {
+} \ No newline at end of file