Martini URL Functions
Overview
The Url
class in Martini provides a suite of utility functions designed for URL manipulation. These functions are essential for handling various aspects of URLs, including extraction of specific parts and constructing URLs from HttpServletRequest
objects. This documentation focuses on demonstrating the use of UrlFunctions
in a Groovy context.
Using UrlFunctions
Groovy offers a straightforward approach to utilize UrlFunctions
. The following examples illustrate some common use cases:
Example 1: Retrieving Base URL from a HttpServletRequest
This example demonstrates how to obtain the base URL from a HttpServletRequest
object.
1 2 3 4 5 |
|
Example 2: Extracting File Name from URL
In this example, we extract the file name from a URL using the filenameFromUrl
method.
1 2 |
|