# Passenger::DirectoryMapper Class Reference
[Core Apache-related classes and functions]

Utility class for determining URI-to-application directory mappings. More...

`#include <DirectoryMapper.h>`

List of all members.

## Public Member Functions

| DirectoryMapper (request_rec *r, DirConfig *config, CachedFileStat *cstat, unsigned int throttleRate)
| Create a new DirectoryMapper object.
const char * | getBaseURI ()
| Determine whether the given HTTP request falls under one of the specified RailsBaseURIs or RackBaseURIs.
string | getPublicDirectory ()
| Returns the filename of the 'public' directory of the Rails/Rack application that's associated with the HTTP request.
ApplicationType | getApplicationType ()
| Returns the application type that's associated with the HTTP request.
const char * | getApplicationTypeString ()
| Returns the application type (as a string) that's associated with the HTTP request.
const char * | getEnvironment ()
| Returns the environment under which the application should be spawned.

## Detailed Description

Utility class for determining URI-to-application directory mappings.

Given a URI, it will determine whether that URI belongs to a Phusion Passenger-handled application, what the base URI of that application is, and what the associated 'public' directory is.

Note:
  This class is not thread-safe, but is reentrant.

## Constructor & Destructor Documentation

Passenger::DirectoryMapper::DirectoryMapper | ( | request_rec * | r,
|  | DirConfig * | config,
|  | CachedFileStat * | cstat,
|  | unsigned int | throttleRate |
| ) |  |  | `[inline]`

Create a new DirectoryMapper object.

Parameters:

  | cstat | A CachedFileStat object used for statting files.
  | throttleRate | A throttling rate for cstat.

Warning:
  Do not use this object after the destruction of `r`, `config` or `cstat`.

## Member Function Documentation

ApplicationType Passenger::DirectoryMapper::getApplicationType | ( |  | ) | `[inline]`

Returns the application type that's associated with the HTTP request.

Exceptions:

  | FileSystemException | An error occured while examening the filesystem.

const char* Passenger::DirectoryMapper::getApplicationTypeString | ( |  | ) | `[inline]`

Returns the application type (as a string) that's associated with the HTTP request.

Exceptions:

  | FileSystemException | An error occured while examening the filesystem.

const char* Passenger::DirectoryMapper::getBaseURI | ( |  | ) | `[inline]`

Determine whether the given HTTP request falls under one of the specified RailsBaseURIs or RackBaseURIs.

If yes, then the first matching base URI will be returned.

If Rails/Rack autodetection was enabled in the configuration, and the document root seems to be a valid Rails/Rack 'public' folder, then this method will return "/".

Otherwise, NULL will be returned.

Exceptions:

  | FileSystemException | This method might also examine the filesystem in order to detect the application's type. During that process, a FileSystemException might be thrown.

Warning:
  The return value may only be used as long as `config` hasn't been destroyed.

const char* Passenger::DirectoryMapper::getEnvironment | ( |  | ) | `[inline]`

Returns the environment under which the application should be spawned.

Exceptions:

  | FileSystemException | An error occured while examening the filesystem.

string Passenger::DirectoryMapper::getPublicDirectory | ( |  | ) | `[inline]`

Returns the filename of the 'public' directory of the Rails/Rack application that's associated with the HTTP request.

Returns an empty string if the document root of the HTTP request cannot be determined, or if it isn't a valid folder.

Exceptions:

  | FileSystemException | An error occured while examening the filesystem.

The documentation for this class was generated from the following file:

- DirectoryMapper.h