Star

Created With

linkreject() operator

Will reject incoming request with given status and message:

1import { reject } from 'rxxpress';

2

3router.get('/')

4.pipe(

5 reject(418, 'I am indeed a teapot!')

6)

7.subscribe();

Reject will only respond to the request if it was not already responded to, making it useful for fallbacks:

1router.use('/')

2.pipe(

3 use(subRouter1),

4 use(subRouter2),

5 reject(404) // --> basically, give out a 404 if no sub-router responds

6)

7.subscribe();


linkAliases

You can use badrequest(), unauthorized(), forbidden() or notfound() instead of reject(). They are identical, except that they respond with corresponding http status (400, 401, 403, 404):

1import { badrequest, unauthorized, forbidden, notfound } from 'rxxpress';

2

3router.use('/')

4.pipe(

5 use(subRouter1),

6 use(subRouter2),

7 notfound()

8)

9.subscribe();

Or with a custom message:

1router.use('/')

2.pipe(

3 use(subRouter1),

4 use(subRouter2),

5 notfound('Weird URL man')

6)

7.subscribe();


linkPacket Flow

reject() (and its aliases) do not pass down incoming packets:

1router.get('/')

2.pipe(

3 forbidden(),

4 tap(() => console.log('Got Here!')) // --> YOU WILL NEVER GET HERE!

5)

6.subscribe();

So in this example, you will never get to the console log.

reject() operatorAliasesPacket Flow

Home Router

Operatorschevron_right

Error Handling