wwProcess::OnUrlRewrite

Use this method if you're using URL rewriting to create extensionless URLs. This method can intercept request routing and take action based on the extensionless path segments.

Note that this method depends on a rewrite rule being in place, and wwProcess::UrlRewriteHandler getting fired by the rewrite rule.

o.OnUrlRewrite(loRewrite, lvParm1)

Parameters

loRewrite
Receives a loRewrite structure that contains the following properties:

  • oPathSegments
    A collection of segments between slashes of the URL.

  • cOriginalUrl
    The full original Url.

  • cOriginalPath
    The logical path URL which is server relative and doesn't include the querystring

  • lIsRouted
    Determines whether this request was rewritten by IIS or other URL rewriter.

lvParm1
A single optional parameter that can be passed in. This is primarily to support JSON objects passed to wwRestProcess so they can be passed through the UrlRewriteHandler() method that handles the method routing.

Example

A typical implementation might look like this for urls like:

api/customer/2341

FUNCTION OnUrlRewrite(loRewrite, lvParm1)

this.oRewrite = loRewrite

*** Assume second segment is our method name
IF loRewrite.oPathSegments.Count > 1
   this.cRestMethod = loRewrite.oPathSegments.Item(2)      
   IF VARTYPE(lvParm1) = "L"
	   RETURN EVALUATE("THIS." + this.cRestMethod  + "()")   
   ELSE
       RETURN EVALUATE("THIS." + this.cRestMethod  + "(lvParm1)")   
   ENDIF
ENDIF

this.ErrorMsg("Invalid Route",;
   "Route values must at least include 1 segments relative to the virtual or root application")

ENDFUNC

See also:

Class wwProcess | wwUtils::CopyObjectProperties

© West Wind Technologies, 1996-2022 • Updated: 10/04/15
Comment or report problem with topic