sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[livejournal] r20425: OPSC-399: Endpoint /__api_endpoint/* to ...

Committer: vtroitsky
OPSC-399: Endpoint /__api_endpoint/* to accept LJ OS API requests on www.* users.* and games.* domains
U   trunk/cgi-bin/Apache/LiveJournal.pm
U   trunk/cgi-bin/LJ/URI.pm
Modified: trunk/cgi-bin/Apache/LiveJournal.pm
===================================================================
--- trunk/cgi-bin/Apache/LiveJournal.pm	2011-10-24 14:22:40 UTC (rev 20424)
+++ trunk/cgi-bin/Apache/LiveJournal.pm	2011-10-25 09:18:44 UTC (rev 20425)
@@ -1078,15 +1078,11 @@
             my $view = $determine_view->($user, "safevhost", $uri);
             return $view if defined $view;
         }
-        elsif ( $func eq 'api' ) {
+        elsif ( $func eq 'api' || LJ::Request->uri =~ /^\/__api_endpoint.*$/) {
             Apache::LiveJournal::Interface::Api->load;
             LJ::Request->handler("perl-script");
             LJ::Request->push_handlers(PerlHandler => \&Apache::LiveJournal::Interface::Api::handler);
             return LJ::Request::OK;
-
-            LJ::Request->pnotes ('error' => 'e404');
-            LJ::Request->pnotes ('remote' => LJ::get_remote());
-            return LJ::Request::NOT_FOUND;
         }
         elsif ( $func eq "games" ) {
             LJ::get_remote();

Modified: trunk/cgi-bin/LJ/URI.pm
===================================================================
--- trunk/cgi-bin/LJ/URI.pm	2011-10-24 14:22:40 UTC (rev 20424)
+++ trunk/cgi-bin/LJ/URI.pm	2011-10-25 09:18:44 UTC (rev 20425)
@@ -15,6 +15,14 @@
     return LJ::Request::OK;
 }
 
+sub api_handler {
+    my ($class) = @_;
+    Apache::LiveJournal::Interface::Api->load;
+    LJ::Request->handler("perl-script");
+    LJ::Request->push_handlers(PerlHandler => \&Apache::LiveJournal::Interface::Api::handler);
+    return LJ::Request::OK;
+}
+
 # Handle a URI. Returns response if success, undef if not handled
 # Takes URI and Apache $r
 sub handle {
@@ -29,6 +37,11 @@
         return LJ::URI->bml_handler($bml_handler_path) if $bml_handler_path;
     }
 
+    # handle "API" endpoint
+    if ($uri =~ /^\/__api_endpoint.*$/) {
+        return LJ::URI->api_handler();        
+    }
+
     ## URI "/pics" can be handle only under user domains
     return undef if $uri =~ /^\/pics/;
 

Tags: livejournal, pm, sunnyman, vtroitsky
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments