r.pipe
HttpEffect route builder based on IxMonad

Importing

1
import { r } from '@marblejs/http';
Copied!

pipe

r namespace function. Creates pipeable RouteEffect builder.

Type declaration

1
pipe :: ...Arity<IxBuilder, IxBuilder> -> RouteEffect
Copied!
r.pipe builder pays attention to the order of applied operators.
1
const example$ = r.pipe(
2
r.matchPath('/'),
3
r.matchType('GET'),
4
r.use(middleware_1$),
5
r.useEffect(req$ => req$.pipe(
6
// ...
7
)),
8
r.use(middleware_2$), // ❌ type error!
9
);
10
11
// or
12
13
const example$ = r.pipe(
14
r.matchType('GET'),
15
r.matchPath('/'), // ❌ type error!
16
r.use(middleware_1$),
17
r.use(middleware_2$),
18
r.useEffect(req$ => req$.pipe(
19
// ...
20
)),
21
);
Copied!
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

1
matchPath :: string -> IxBuilder -> IxBuilder
Copied!

Parameters

parameter
definition
path
string

matchType

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

Type declaration

1
matchType :: HttpMethod -> IxBuilder -> IxBuilder
Copied!

Parameters

parameter
definition
path
HttpMethod

use

r namespace function. Registers HTTP middleware with connected HttpEffect.

Type declaration

1
use :: HttpMiddlewareEffect -> IxBuilder -> IxBuilder
Copied!

Parameters

parameter
definition
middleware
HttpMiddlewareEffect

useEffect

r namespace function. Registers HttpEffect.

Type declaration

1
useEffect :: HttpEffect -> IxBuilder -> IxBuilder
Copied!

Parameters

parameter
definition
effect
HttpEffect

applyMeta

r namespace function. Applies metadata to connected HttpEffect.

Type declaration

1
applyMeta :: RouteMeta -> IxBuilder -> IxBuilder
Copied!

Parameters

parameter
definition
meta
RouteMeta
RouteMeta attributes:
parameter
type
definition
name
<optional> string
route/effect name
continuous
<optional> boolean
enables continuous mode
overridable
<optional> boolean
if true, the route can be overrode by another route

Example

1
import { r } from '@marblejs/http';
2
3
const example$ = r.pipe(
4
r.applyMeta({ continuous: true }),
5
r.matchPath('/'),
6
r.matchType('GET'),
7
r.use(middleware_1$),
8
r.use(middleware_2$),
9
r.useEffect(req$ => req$.pipe(
10
// ...
11
)),
12
r.applyMeta({ meta_1: /* ... */ }),
13
r.applyMeta({ meta_1: /* ... */ }),
14
);
Copied!
Last modified 1mo ago