I want to reuse http.handler by reference it’s name, like this:
{
"apps": {
"config": {
"http": {
"handlers": [
{
"name": "reqbody<10m",
"config": {
"handler": "request_body",
"max_size": 10485760
}
},
{
"name": "accesslog_xxx",
"config": {
"handler": "accesslog_xxx"
}
},
{
"name": "proxy_to_xxx",
"config": {
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"host": [
"xxx.com"
]
}
}
},
"upstreams": [
{
"dial": "xxx.com:80"
}
]
}
}
]
}
}
},
"http": {
"servers": {
"demo": {
// ...
"routes": [
{
"handle": [
{
"handler": "group",
"handler_names": [
"reqbody<10m",
"accesslog_xxx",
"proxy_to_xxx"
]
}
],
"match": [
{
"path": [
"/*"
]
}
]
}
],
"write_timeout": "30s"
}
}
}
}
}
}
thus, we can separate the handler definition and usage, I think it makes the configuration clearer, what do you think about?
About implementation, I came up with two options:
- like the above config, I implement it in a custom config App, which will be provisioned before http App;
- add a dummy route as first route, then define named handlers there.
I think if its best define named handlers in http
block or server
block? But it seems that there is no proper extension point.