NAME

wyrm_uriMethod — Select and evaluate URI method.

synopsis

#include "wyrm-uri.h"

int wyrm_uriMethod(Intr intr,Obj uri,chars method,int N,Obj *P);

description

This package provides an object orientish way to use URIs, with the URI scheme identifying the kind of objects. URIs can be parsed with parts extracted, replaced, or added. A method can be identified from the scheme and then evaluated. The objects are stored in an OAV mapping and use OAV delegation and parent identification. This OAV mapping is called the urispace.

A URI is a Uniform Resource Indicator and a URL is a Uniform Resource Locator, a subset of URIs. The other kind of URI is the experimental URN Uniform Resource Name. A URL indicates one specific location of a resource and how to access it. A URN indicates a resource in general; the URN must then be resolved to a URL automatically. URNs are still experimental; in practice all URIs are just URLs. These routines can however manipulate both URLs and URNs.

Each URI belongs to a scheme, such as 'ftp' or 'telnet'. The scheme begins the URI (except the relative scheme). A URI without a beginning scheme is always the '(relative)' scheme URL. If the scheme cannot be identified in the urispace OAV mapping, it is treated as a generic scheme.

The syntax of a URI depends on its scheme; the syntax defines the URI as sequence of parts with various delimiters. For example, with the URL 'ftp://hodgepodge/x/y/z;type=d', the scheme is 'ftp' and the parts are 'scheme' (ftp), 'host' (hodgepodge), 'path' (/x/y/z), and the 'parameter' (;type=d). The 'ftp' scheme has additional parts such as 'user' and 'port' which are empty in this specific URI. Each part of a URI is named; these names are used to extract, replace, and remove parts in parsed URIs. Part names are case sensitive.

uri method uri P1...PN
is equivalent to
oav do [uri space] uri.[uri part uri scheme].method uri P1...PN

Before seeking the method in the the urispace, uri attempts to get the value of the variable subst.uri in the urispace. If the value is found, this is substituted for the uri given in the command. And so the actual example above would be closer to

if {![catch {uri get [uri space] uri} substitution]} {
oav do [uri space] uri.[uri part $substitution scheme].method $substitution P1...PN
} else {
oav do [uri space] uri.[uri part uri scheme].method uri P1...PN
}
This can be used to implement such things as caches.

wyrm_uriMethod finds the method in the urispace and evaluates it.

SEE ALSO

oav (1WY), uri (1WY), urispace (4WY), wyrm_uriGet (3WY), wyrm_uriAbsolutise (3WY), wyrm_urispace (3WY).