---
lang: en
title: 'API docs: context.intercept'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.context.intercept.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [intercept](./context.intercept.md)

## intercept() function

Decorator function `@intercept` for classes/methods to apply interceptors. It can be applied on a class and its public methods. Multiple occurrences of `@intercept` are allowed on the same target class or method. The decorator takes a list of `interceptor` functions or binding keys.

<b>Signature:</b>

```typescript
export declare function intercept(...interceptorOrKeys: InterceptorOrKey[]): (target: any, method?: string | undefined, methodDescriptor?: TypedPropertyDescriptor<any> | undefined) => any;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  interceptorOrKeys | <code>InterceptorOrKey[]</code> | One or more interceptors or binding keys that are resolved to be interceptors |

<b>Returns:</b>

`(target: any, method?: string | undefined, methodDescriptor?: TypedPropertyDescriptor<any> | undefined) => any`

## Example


```ts
@intercept(log, metrics)
class MyController {
  @intercept('caching-interceptor')
  @intercept('name-validation-interceptor')
  greet(name: string) {
    return `Hello, ${name}`;
  }
}

```


