source: bookmarks/trunk/index.cgi @ 41

Last change on this file since 41 was 41, checked in by peter, 11 years ago
  • move the reverse proxy check and change to SERVER_NAME from the BookmarkApp to the index.cgi script
  • the dbname is passed in as a parameter to BookmarkApp
  • Property svn:executable set to *
File size: 1.0 KB
RevLine 
[2]1#!/usr/bin/perl -w
2use strict;
3
[23]4package BookmarkApp::Dispatch;
5use base 'CGI::Application::Dispatch';
6
7sub dispatch_args {
8    return {
9        table => [
[30]10            '[get]'           => { app => 'BookmarkApp', rm => 'list' },
11            'list[get]'       => { app => 'BookmarkApp', rm => 'list' },
12            'feed[get]'       => { app => 'BookmarkApp', rm => 'feed' },
13            ':id[get]'        => { app => 'BookmarkApp', rm => 'view' },
14            ':id/:field[get]' => { app => 'BookmarkApp', rm => 'view_field' },
15            ':id?[post]'      => { app => 'BookmarkApp', rm => 'edit' },
[23]16        ],
17    };
18}
19
20package main;
[41]21# check for whether we are behind a reverse proxy, and adjust the SERVER_NAME accordingly
22# TODO: use something like Plack::Middlware::ReverseProxy instead
23$ENV{SERVER_NAME} = $ENV{HTTP_X_FORWARDED_HOST} if $ENV{HTTP_X_FORWARDED_HOST};
24
25BookmarkApp::Dispatch->dispatch(
26    args_to_new => {
27        #TODO: dbname should be in a config file
28        PARAMS => { dbname => 'fk.db' },
29    }
30);
Note: See TracBrowser for help on using the repository browser.