-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14a926d
commit b7e5120
Showing
4 changed files
with
317 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!-- Shared between KIC and KGO plugin installation --> | ||
## Create a custom plugin | ||
|
||
1. Create a directory with test plugin code. | ||
|
||
{:.note} | ||
> If you already have a real plugin, you can skip this step. | ||
```bash | ||
mkdir myheader | ||
echo 'local MyHeader = {} | ||
MyHeader.PRIORITY = 1000 | ||
MyHeader.VERSION = "1.0.0" | ||
function MyHeader:header_filter(conf) | ||
-- do custom logic here | ||
kong.response.set_header("myheader", conf.header_value) | ||
end | ||
return MyHeader | ||
' > myheader/handler.lua | ||
|
||
echo 'return { | ||
name = "myheader", | ||
fields = { | ||
{ config = { | ||
type = "record", | ||
fields = { | ||
{ header_value = { type = "string", default = "roar", }, }, | ||
}, | ||
}, }, | ||
} | ||
} | ||
' > myheader/schema.lua | ||
``` | ||
|
||
After your plugin code available in a directory, the directory should look like this: | ||
|
||
```bash | ||
tree myheader | ||
``` | ||
|
||
```bash | ||
myheader | ||
├── handler.lua | ||
└── schema.lua | ||
0 directories, 2 files | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.