Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions docs/api/v4.2.0.json

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions web/sites/api/src/content/docs/v4-2-0/configuration/addformat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: addFormat()
description: "Adds a new MIME type to your Wheels application for use with responding to multiple formats."
sidebar:
label: addFormat()
order: 0
---

## Signature

`addFormat()` — returns `void`

**Available in:** `controller`, `model`, `mapper`, `migrator`, `migration`, `tabledefinition`
**Category:** Miscellaneous Functions

## Description

Adds a new MIME type to your Wheels application for use with responding to multiple formats.



## Parameters

<div class="wd-params-table">

| Name | Type | Required | Default | Description |
| ---- | ---- | -------- | ------- | ----------- |
| `extension` | `string` | yes | — | File extension to add. |
| `mimeType` | `string` | yes | — | Matching MIME type to associate with the file extension. |

</div>

## Examples

<pre><code class='javascript'>// 1. Add the `js` format
addFormat(extension=&quot;js&quot;, mimeType=&quot;text/javascript&quot;);

// 2. Add the `ppt` and `pptx` formats
addFormat(extension=&quot;ppt&quot;, mimeType=&quot;application/vnd.ms-powerpoint&quot;);
addFormat(extension=&quot;pptx&quot;, mimeType=&quot;application/vnd.ms-powerpoint&quot;);

// 3. Add a custom `csv` format so controllers can respond with `responds(formats=&quot;csv&quot;)`
addFormat(extension=&quot;csv&quot;, mimeType=&quot;text/csv&quot;);
</code></pre>
86 changes: 86 additions & 0 deletions web/sites/api/src/content/docs/v4-2-0/configuration/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
title: api()
description: "Scope routes under an API path prefix. Shorthand for <code>.group(path=\"api\", name=\"api\", ...)</code>. Typically used in combination with <code>version()</code>"
sidebar:
label: api()
order: 0
---

## Signature

`api()` — returns `struct`

**Available in:** `mapper`
**Category:** Routing

## Description

Scope routes under an API path prefix. Shorthand for <code>.group(path="api", name="api", ...)</code>. Typically used in combination with <code>version()</code> to organize versioned API endpoints.



## Parameters

<div class="wd-params-table">

| Name | Type | Required | Default | Description |
| ---- | ---- | -------- | ------- | ----------- |
| `path` | `string` | no | `api` | URL path prefix for the API. Defaults to `"api"`. |
| `name` | `string` | no | `api` | Name prefix for route names. Defaults to `"api"`. |
| `constraints` | `struct` | no | — | Variable patterns to apply to all child routes. |
| `callback` | `any` | no | — | A callback function to define nested routes within this API scope. |

</div>

## Examples

<pre><code class='javascript'>&lt;cfscript&gt;

// 1. Basic API scope using the default path and name prefix &quot;api&quot;
mapper()
.api()
// Route name: apiUsers
// Example URL: /api/users
.resources(&quot;users&quot;)
.end()
.end();

// 2. Combine api() with version() for versioned API endpoints
mapper()
.api()
.version(1)
// Route name: apiV1Users
// Example URL: /api/v1/users
.resources(&quot;users&quot;)
.end()

.version(2)
// Route name: apiV2Products
// Example URL: /api/v2/products
.resources(&quot;products&quot;)
.end()
.end()
.end();

// 3. Override the default path and name prefixes
mapper()
.api(path=&quot;public-api&quot;, name=&quot;publicApi&quot;)
// Route name: publicApiOrders
// Example URL: /public-api/orders
.resources(&quot;orders&quot;)
.end()
.end();

// 4. Use api() with a callback to avoid manual .end() calls
mapper()
.api(callback=function(m) {
m.version(number=1, callback=function(m) {
// Route name: apiV1Users
// Example URL: /api/v1/users
m.resources(&quot;users&quot;);
});
})
.end();

&lt;/cfscript&gt;
</code></pre>
48 changes: 48 additions & 0 deletions web/sites/api/src/content/docs/v4-2-0/configuration/collection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: collection()
description: "A collection route doesn't require an id because it acts on a collection of objects."
sidebar:
label: collection()
order: 0
---

## Signature

`collection()` — returns `struct`

**Available in:** `mapper`
**Category:** Routing

## Description

A collection route doesn't require an id because it acts on a collection of objects.
photos/search is an example of a collection route, because it acts on (and displays) a collection of objects.




## Examples

<pre><code class='javascript'>&lt;cfscript&gt;

// 1. Add a search route acting on the photos collection (GET /photos/search)
mapper()
.resources(name=&quot;photos&quot;, nested=true)
.collection()
.get(&quot;search&quot;)
.end()
.end()
.end();

// 2. Add multiple collection routes (GET /articles/featured, POST /articles/bulk-delete)
mapper()
.resources(name=&quot;articles&quot;, nested=true)
.collection()
.get(&quot;featured&quot;)
.post(&quot;bulkDelete&quot;)
.end()
.end()
.end();

&lt;/cfscript&gt;
</code></pre>
41 changes: 41 additions & 0 deletions web/sites/api/src/content/docs/v4-2-0/configuration/constraints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: constraints()
description: "Set variable patterns to use for matching."
sidebar:
label: constraints()
order: 0
---

## Signature

`constraints()` — returns `struct`

**Available in:** `mapper`
**Category:** Routing

## Description

Set variable patterns to use for matching.




## Examples

<pre><code class='javascript'>&lt;cfscript&gt;

mapper()
// 1. Constrain a dynamic segment to digits only
.constraints(id=&quot;[0-9]+&quot;)
.resources(name=&quot;articles&quot;)
.end()

// 2. Constrain multiple segments — numeric id and lowercase-only slug
.constraints(id=&quot;[0-9]+&quot;, slug=&quot;[a-z\-]+&quot;)
.get(name=&quot;article&quot;, to=&quot;articles##show&quot;)
.get(name=&quot;articleBySlug&quot;, to=&quot;articles##showBySlug&quot;)
.end()
.end();

&lt;/cfscript&gt;
</code></pre>
33 changes: 33 additions & 0 deletions web/sites/api/src/content/docs/v4-2-0/configuration/controller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: controller()
description: "Considered deprecated as this doesn't conform to RESTful routing principles; Try not to use this."
sidebar:
label: controller()
order: 0
---

## Signature

`controller()` — returns `struct`

**Available in:** `mapper`
**Category:** Routing

## Description

Considered deprecated as this doesn't conform to RESTful routing principles; Try not to use this.



## Parameters

<div class="wd-params-table">

| Name | Type | Required | Default | Description |
| ---- | ---- | -------- | ------- | ----------- |
| `controller` | `string` | yes | — | |
| `name` | `string` | no | `[runtime expression]` | |
| `path` | `string` | no | `[runtime expression]` | |

</div>

81 changes: 81 additions & 0 deletions web/sites/api/src/content/docs/v4-2-0/configuration/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: delete()
description: "Create a route that matches a URL requiring an HTTP <code>DELETE</code> method. We recommend using this matcher to expose actions that delete database records."
sidebar:
label: delete()
order: 0
---

## Signature

`delete()` — returns `struct`

**Available in:** `mapper`
**Category:** Routing

## Description

Create a route that matches a URL requiring an HTTP <code>DELETE</code> method. We recommend using this matcher to expose actions that delete database records.



## Parameters

<div class="wd-params-table">

| Name | Type | Required | Default | Description |
| ---- | ---- | -------- | ------- | ----------- |
| `name` | `string` | no | — | Camel-case name of route to reference when build links and form actions (e.g., `blogPost`). |
| `pattern` | `string` | no | — | Overrides the URL pattern that will match the route. The default value is a dasherized version of `name` (e.g., a `name` of `blogPost` generates a pattern of `blog-post`). |
| `to` | `string` | no | — | Set `controller##action` combination to map the route to. You may use either this argument or a combination of `controller` and `action`. |
| `controller` | `string` | no | — | Map the route to a given controller. This must be passed along with the `action` argument. |
| `action` | `string` | no | — | Map the route to a given action within the `controller`. This must be passed along with the `controller` argument. |
| `package` | `string` | no | — | Indicates a subfolder that the controller will be referenced from (but not added to the URL pattern). For example, if you set this to `admin`, the controller will be located at `admin/YourController.cfc`, but the URL path will not contain `admin/`. |
| `on` | `string` | no | — | If this route is within a nested resource, you can set this argument to `member` or `collection`. A `member` route contains a reference to the resource's `key`, while a `collection` route does not. |
| `redirect` | `string` | no | — | Redirect via 302 to this URL when this route is matched. Has precedence over controller/action. Use either an absolute link like `/about/`, or a full canonical link. |

</div>

## Examples

<pre><code class='javascript'>&lt;cfscript&gt;

mapper()
// Route name: articleReview
// Example URL: /articles/987/reviews/12542
// Controller: Reviews
// Action: delete
.delete(name=&quot;articleReview&quot;, pattern=&quot;articles/[articleKey]/reviews/[key]&quot;, to=&quot;reviews##delete&quot;)

// Route name: cookedBooks
// Example URL: /cooked-books
// Controller: CookedBooks
// Action: delete
.delete(name=&quot;cookedBooks&quot;, controller=&quot;cookedBooks&quot;, action=&quot;delete&quot;)

// Route name: logout
// Example URL: /logout
// Controller: Sessions
// Action: delete
.delete(name=&quot;logout&quot;, to=&quot;sessions##delete&quot;)

// Route name: clientsStatus
// Example URL: /statuses/4918
// Controller: clients.Statuses
// Action: delete
.delete(name=&quot;statuses&quot;, to=&quot;statuses##delete&quot;, package=&quot;clients&quot;)

// Route name: blogComment
// Example URL: /comments/5432
// Controller: blog.Comments
// Action: delete
.delete(
name=&quot;comment&quot;,
pattern=&quot;comments/[key]&quot;,
to=&quot;comments##delete&quot;,
package=&quot;blog&quot;
)
.end();

&lt;/cfscript&gt;
</code></pre>
40 changes: 40 additions & 0 deletions web/sites/api/src/content/docs/v4-2-0/configuration/end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: end()
description: "Call this to end a nested routing block or the entire route configuration. This method is chained on a sequence of routing mapper method calls started by <code>"
sidebar:
label: end()
order: 0
---

## Signature

`end()` — returns `struct`

**Available in:** `mapper`
**Category:** Routing

## Description

Call this to end a nested routing block or the entire route configuration. This method is chained on a sequence of routing mapper method calls started by <code>mapper()</code>.




## Examples

<pre><code class='javascript'>&lt;cfscript&gt;

mapper()
.namespace(&quot;admin&quot;)
.resources(&quot;products&quot;)
.end() // Ends the `namespace` block.

.scope(package=&quot;public&quot;)
.resources(name=&quot;products&quot;, nested=true)
.resources(&quot;variations&quot;)
.end() // Ends the nested `resources` block.
.end() // Ends the `scope` block.
.end(); // Ends the `mapper` block.

&lt;/cfscript&gt;
</code></pre>
Loading
Loading