Module webmachine_router

Module to add and remove dynamic routes to webmachine's routing table.

Copyright © 2007-2010 Basho Technologies Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Behaviours: gen_server.

Authors: Kevin A. Smith (ksmith@basho.com).

Description

Module to add and remove dynamic routes to webmachine's routing table. Dynamic routes are not persistent between executions of a webmachine application. They will need to be added to the the table each time webmachine restarts.

Data Types

hostmatchterm()

hostmatchterm() = {hostmatch(), [pathmatchterm()]}

The dispatch configuration contains a list of these terms, and the first one whose host and one pathmatchterm match is used.

matchmod()

matchmod() = atom()

This atom, if present in a successful matchterm, will appear in the resulting dispterm. In Webmachine this is used to name the resource module that will handle the matching request.

matchopts()

matchopts() = [term()]

This term, if present in a successful matchterm, will appear in the resulting dispterm. In Webmachine this is used to provide arguments to the resource module handling the matching request.

pathmatchterm()

pathmatchterm() = {[pathterm()], matchmod(), matchopts()}

The dispatch configuration contains a list of these terms, and the first one whose list of pathterms matches the input path is used.

pathterm()

pathterm() = '*' | string() | atom()

A list of pathterms is matched against a '/'-separated input path. The '*' pathterm matches all remaining tokens. A string pathterm will match a token of exactly the same string. Any atom pathterm other than '*' will match any token and will create a binding in the result if a complete match occurs.

Function Index

add_route/1Adds a route to webmachine's route table.
remove_resource/1Removes all routes for a specific resource module.
remove_route/1Removes a route from webamchine's route table.
start_link/0Starts the webmachine_router gen_server.

Function Details

add_route/1

add_route(Route::hostmatchterm() | pathmatchterm()) -> ok

Adds a route to webmachine's route table. The route should be the format documented here: http://bitbucket.org/justin/webmachine/wiki/DispatchConfiguration

remove_resource/1

remove_resource(Resource::atom()) -> ok

Removes all routes for a specific resource module.

remove_route/1

remove_route(Route::hostmatchterm() | pathmatchterm()) -> ok

Removes a route from webamchine's route table. The route route must be properly formatted

See also: add_route/2.

start_link/0

start_link() -> {ok, pid()} | {error, any()}

Starts the webmachine_router gen_server.


Generated by EDoc, Feb 8 2011, 19:14:54.