> For the complete documentation index, see [llms.txt](https://motivlabs.gitbook.io/janus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://motivlabs.gitbook.io/janus/plugins.md).

# Plugins

Janus can be extended with plugins. Plugins add missing functionality to Janus. They are "plugged in" at compile-time. The plugins are attached to an [API Definition](https://github.com/motiv-labs/janus/tree/2470815283dbbce92900fce0c175b6fb9fc0574f/docs/api-definition/README.md) and you can enable or disable them at any time.

Janus comes with a set of built in plugins that you can add to your API Definitions:

* [CORS](/janus/plugins/cors.md)
* [OAuth2](/janus/plugins/oauth.md)
* [Rate Limit](/janus/plugins/rate_limit.md)
* [Request Transformer](/janus/plugins/request_transformer.md)
* [Compression](/janus/plugins/compression.md)

## How can I create a plugin?

Even though there are different kinds of plugins, the process of creating one is roughly the same for all.

### 1. Create a package and register your plugin.

Start a new Go package with an init function and register your plugin with Janus:

```go
import "github.com/hellofresh/janus/pkg/plugin"

func init() {
    // register a "generic" plugin, like a directive or middleware
    plugin.RegisterPlugin("name", myPlugin)
}
```

Every plugin must have a name and, when applicable, the name must be unique.

### 2. Plug in your plugin.

To plug your plugin into Janus, import it. This is usually done near the top of [loader.go](https://github.com/motiv-labs/janus/tree/2470815283dbbce92900fce0c175b6fb9fc0574f/pgk/loader/loader.go):

```go
import _ "your/plugin/package/path/here"
```

### 3. Write Tests!

Write tests. Get good coverage where possible, and make sure your assertions test what you think they are testing! Use go vet and go test -race to ensure your plugin is as error-free as possible.

### 4. Maintain your plugin.

People will use plugins that are useful, clearly documented, easy to use, and maintained by their owner. And congratulations, you're a Janus plugin author!


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://motivlabs.gitbook.io/janus/plugins.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
