Guest User

Untitled

a guest
Jan 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. package DoubleSpark::Web::Dispatcher;
  2. use strict;
  3. use warnings;
  4. use Amon2::Web::Dispatcher::RouterSimple;
  5.  
  6. sub get($;$$) { connect_with_method('GET', @_) }
  7. sub post($;$$) { connect_with_method('POST', @_) }
  8.  
  9. get '/' => 'Root#index';
  10. get '/mock' => 'Root#mock';
  11.  
  12. get '/signout' => 'Root#signout';
  13.  
  14. get '/signin/twitter/oauth' => 'Signin::Twitter#oauth';
  15. get '/signin/twitter/callback' => 'Signin::Twitter#callback';
  16.  
  17. get '/api/1/account/info' => 'API::Account#info';
  18. get '/api/1/account/info_with_all' => 'API::Account#info_with_all';
  19. post '/api/1/account/update' => 'API::Account#update';
  20.  
  21. post '/api/1/list/create' => 'API::List#create';
  22. post '/api/1/list/update' => 'API::List#update';
  23. post '/api/1/list/delete' => 'API::List#delete';
  24. post '/api/1/list/clear' => 'API::List#clear';
  25.  
  26. post '/api/1/task/create' => 'API::Task#create';
  27. post '/api/1/task/update' => 'API::Task#update';
  28. post '/api/1/task/move' => 'API::Task#move';
  29.  
  30. post '/api/1/comment/create' => 'API::Comment#create';
  31. post '/api/1/comment/delete' => 'API::Comment#delete';
  32.  
  33. if ($ENV{PLACK_ENV} eq 'development') {
  34. warn router->as_string;
  35. }
  36.  
  37. sub connect_with_method {
  38. my ($method, $path, $dest, $opt) = @_;
  39. $opt->{method} = $method;
  40. if (ref $dest) {
  41. connect $path => $dest, $opt;
  42. } elsif (not $dest) {
  43. connect $path => {}, $opt;
  44. } else {
  45. my %dest;
  46. my ($controller, $action) = split('#', $dest);
  47. $dest{controller} = $controller;
  48. $dest{action} = $action if defined $action;
  49. connect $path => \%dest, $opt;
  50. }
  51. }
Add Comment
Please, Sign In to add comment