# r.pipe

## **Importing**

```typescript
import { r } from '@marblejs/http';
```

## `pipe`

`r` namespace function. Creates pipeable *RouteEffect* builder.

### **Type declaration**

```typescript
pipe :: ...Arity<IxBuilder, IxBuilder> -> RouteEffect
```

{% hint style="warning" %}
`r.pipe` builder pays attention to the order of applied operators.
{% endhint %}

```typescript
const example$ = r.pipe(
  r.matchPath('/'),
  r.matchType('GET'),
  r.use(middleware_1$),
  r.useEffect(req$ => req$.pipe(
    // ...
  )),
  r.use(middleware_2$), // ❌ type error!
);

// or 

const example$ = r.pipe(
  r.matchType('GET'),
  r.matchPath('/'), // ❌ type error!
  r.use(middleware_1$),
  r.use(middleware_2$), 
  r.useEffect(req$ => req$.pipe(
    // ...
  )),
);
```

**Correct order:**

1. **`<optional> applyMeta`**
2. **`matchPath`**
3. **`matchType`**
4. **`use`** \[...]
5. **`useEffect`**
6. **`applyMeta`** \[...]

## **`matchPath`**

`r` namespace function. Matches request path for connected *HttpEffect*.

### **Type declaration**

```typescript
matchPath :: string -> IxBuilder -> IxBuilder
```

### **Parameters**

| *parameter* | definition |
| ----------- | ---------- |
| *path*      | `string`   |

## **`matchType`**

`r` namespace function. Matches HTTP method type for connected *HttpEffect*.

### **Type declaration**

```typescript
matchType :: HttpMethod -> IxBuilder -> IxBuilder
```

### **Parameters**

| *parameter* | definition   |
| ----------- | ------------ |
| *path*      | `HttpMethod` |

## `use`

`r` namespace function. Registers HTTP middleware with connected *HttpEffect.*

### **Type declaration**

```typescript
use :: HttpMiddlewareEffect -> IxBuilder -> IxBuilder
```

### **Parameters**

| *parameter*  | definition             |
| ------------ | ---------------------- |
| *middleware* | `HttpMiddlewareEffect` |

## `useEffect`

`r` namespace function. Registers *HttpEffect.*

### **Type declaration**

```typescript
useEffect :: HttpEffect -> IxBuilder -> IxBuilder
```

### **Parameters**

| *parameter* | definition   |
| ----------- | ------------ |
| *effect*    | `HttpEffect` |

## `applyMeta`

`r` namespace function. Applies metadata to connected *HttpEffect*.

### **Type declaration**

```typescript
applyMeta :: RouteMeta -> IxBuilder -> IxBuilder
```

### **Parameters**

| *parameter* | definition  |
| ----------- | ----------- |
| meta        | `RouteMeta` |

`RouteMeta` attributes:

| parameter     | type                  | definition                                                                      |
| ------------- | --------------------- | ------------------------------------------------------------------------------- |
| `name`        | \<optional> `string`  | route/effect name                                                               |
| `continuous`  | \<optional> `boolean` | enables [continuous mode](https://marblejs.gitbook.io/docs/http/advanced/modes) |
| `overridable` | \<optional> `boolean` | if true, the route can be overrode by another route                             |

## Example

```typescript
import { r } from '@marblejs/http';

const example$ = r.pipe(
  r.applyMeta({ continuous: true }),
  r.matchPath('/'),
  r.matchType('GET'),
  r.use(middleware_1$),
  r.use(middleware_2$),
  r.useEffect(req$ => req$.pipe(
    // ...
  )),
  r.applyMeta({ meta_1: /* ... */ }),
  r.applyMeta({ meta_1: /* ... */ }),
);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://marblejs.gitbook.io/docs/other/api-reference/marblejs-http/r.pipe.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
