In the above example the handler name is index(). The "index" handler is always loaded by default if the second segment of the URI is empty.
Another way to show your "Hello World!" message would be this:
example.com/index.lc/blog/index/
The second segment of the URI determines which handler in the controller gets called. Let's try it. Add a new handler to your controller:
<?rev # PUT YOUR HANDLER NAMES INTO THE GLOBAL gControllerHandlers AS A COMMA SEPARATED LIST put "index,comments" into gControllerHandlers command index put "Hello World!" end index command comments put "Look at this!" end comments
Important: Don't forget to add the name of your new handler to the comma separated list of the variable gControllerHandlers.
Now load the following URL to see the comments handler:
example.com/index.lc/blog/comments/
You should see your new message.
Note: There is currently a limitation with LiveCode Server which does not allow hyphens in handler names. So, don't use hyphens in your handler names as these yield an error.
If your URI contains more than two segments you can retrieve them using the rigFetchSegment() function. For example, lets say you have a URI like this:
As noted above, the second segment of the URI typically determines which handler in the controller gets called.
In some cases you may want certain handlers hidden from public access. To make a handler private, simply add an underscore as the name prefix and it will not be served via a URL request.
Since your controller script will extend the main application controller you must be careful not to name your handlers identically to the ones used by that library.