| 1 |
localhost |
| 2 |
|
| 3 |
respond "To intercept" |
| 4 |
|
| 5 |
intercept { |
| 6 |
@500 status 500 |
| 7 |
replace_status @500 400 |
| 8 |
|
| 9 |
@all status 2xx 3xx 4xx 5xx |
| 10 |
replace_status @all {http.error.status_code} |
| 11 |
|
| 12 |
replace_status {http.error.status_code} |
| 13 |
|
| 14 |
@accel header X-Accel-Redirect * |
| 15 |
handle_response @accel { |
| 16 |
respond "Header X-Accel-Redirect!" |
| 17 |
} |
| 18 |
|
| 19 |
@another { |
| 20 |
header X-Another * |
| 21 |
} |
| 22 |
handle_response @another { |
| 23 |
respond "Header X-Another!" |
| 24 |
} |
| 25 |
|
| 26 |
@401 status 401 |
| 27 |
handle_response @401 { |
| 28 |
respond "Status 401!" |
| 29 |
} |
| 30 |
|
| 31 |
handle_response { |
| 32 |
respond "Any! This should be last in the JSON!" |
| 33 |
} |
| 34 |
|
| 35 |
@403 { |
| 36 |
status 403 |
| 37 |
} |
| 38 |
handle_response @403 { |
| 39 |
respond "Status 403!" |
| 40 |
} |
| 41 |
|
| 42 |
@multi { |
| 43 |
status 401 403 |
| 44 |
status 404 |
| 45 |
header Foo * |
| 46 |
header Bar * |
| 47 |
} |
| 48 |
handle_response @multi { |
| 49 |
respond "Headers Foo, Bar AND statuses 401, 403 and 404!" |
| 50 |
} |
| 51 |
} |
| 52 |
---------- |
| 53 |
{ |
| 54 |
"apps": { |
| 55 |
"http": { |
| 56 |
"servers": { |
| 57 |
"srv0": { |
| 58 |
"listen": [ |
| 59 |
":443" |
| 60 |
], |
| 61 |
"routes": [ |
| 62 |
{ |
| 63 |
"match": [ |
| 64 |
{ |
| 65 |
"host": [ |
| 66 |
"localhost" |
| 67 |
] |
| 68 |
} |
| 69 |
], |
| 70 |
"handle": [ |
| 71 |
{ |
| 72 |
"handler": "subroute", |
| 73 |
"routes": [ |
| 74 |
{ |
| 75 |
"handle": [ |
| 76 |
{ |
| 77 |
"handle_response": [ |
| 78 |
{ |
| 79 |
"match": { |
| 80 |
"status_code": [ |
| 81 |
500 |
| 82 |
] |
| 83 |
}, |
| 84 |
"status_code": 400 |
| 85 |
}, |
| 86 |
{ |
| 87 |
"match": { |
| 88 |
"status_code": [ |
| 89 |
2, |
| 90 |
3, |
| 91 |
4, |
| 92 |
5 |
| 93 |
] |
| 94 |
}, |
| 95 |
"status_code": "{http.error.status_code}" |
| 96 |
}, |
| 97 |
{ |
| 98 |
"match": { |
| 99 |
"headers": { |
| 100 |
"X-Accel-Redirect": [ |
| 101 |
"*" |
| 102 |
] |
| 103 |
} |
| 104 |
}, |
| 105 |
"routes": [ |
| 106 |
{ |
| 107 |
"handle": [ |
| 108 |
{ |
| 109 |
"body": "Header X-Accel-Redirect!", |
| 110 |
"handler": "static_response" |
| 111 |
} |
| 112 |
] |
| 113 |
} |
| 114 |
] |
| 115 |
}, |
| 116 |
{ |
| 117 |
"match": { |
| 118 |
"headers": { |
| 119 |
"X-Another": [ |
| 120 |
"*" |
| 121 |
] |
| 122 |
} |
| 123 |
}, |
| 124 |
"routes": [ |
| 125 |
{ |
| 126 |
"handle": [ |
| 127 |
{ |
| 128 |
"body": "Header X-Another!", |
| 129 |
"handler": "static_response" |
| 130 |
} |
| 131 |
] |
| 132 |
} |
| 133 |
] |
| 134 |
}, |
| 135 |
{ |
| 136 |
"match": { |
| 137 |
"status_code": [ |
| 138 |
401 |
| 139 |
] |
| 140 |
}, |
| 141 |
"routes": [ |
| 142 |
{ |
| 143 |
"handle": [ |
| 144 |
{ |
| 145 |
"body": "Status 401!", |
| 146 |
"handler": "static_response" |
| 147 |
} |
| 148 |
] |
| 149 |
} |
| 150 |
] |
| 151 |
}, |
| 152 |
{ |
| 153 |
"match": { |
| 154 |
"status_code": [ |
| 155 |
403 |
| 156 |
] |
| 157 |
}, |
| 158 |
"routes": [ |
| 159 |
{ |
| 160 |
"handle": [ |
| 161 |
{ |
| 162 |
"body": "Status 403!", |
| 163 |
"handler": "static_response" |
| 164 |
} |
| 165 |
] |
| 166 |
} |
| 167 |
] |
| 168 |
}, |
| 169 |
{ |
| 170 |
"match": { |
| 171 |
"headers": { |
| 172 |
"Bar": [ |
| 173 |
"*" |
| 174 |
], |
| 175 |
"Foo": [ |
| 176 |
"*" |
| 177 |
] |
| 178 |
}, |
| 179 |
"status_code": [ |
| 180 |
401, |
| 181 |
403, |
| 182 |
404 |
| 183 |
] |
| 184 |
}, |
| 185 |
"routes": [ |
| 186 |
{ |
| 187 |
"handle": [ |
| 188 |
{ |
| 189 |
"body": "Headers Foo, Bar AND statuses 401, 403 and 404!", |
| 190 |
"handler": "static_response" |
| 191 |
} |
| 192 |
] |
| 193 |
} |
| 194 |
] |
| 195 |
}, |
| 196 |
{ |
| 197 |
"status_code": "{http.error.status_code}" |
| 198 |
}, |
| 199 |
{ |
| 200 |
"routes": [ |
| 201 |
{ |
| 202 |
"handle": [ |
| 203 |
{ |
| 204 |
"body": "Any! This should be last in the JSON!", |
| 205 |
"handler": "static_response" |
| 206 |
} |
| 207 |
] |
| 208 |
} |
| 209 |
] |
| 210 |
} |
| 211 |
], |
| 212 |
"handler": "intercept" |
| 213 |
}, |
| 214 |
{ |
| 215 |
"body": "To intercept", |
| 216 |
"handler": "static_response" |
| 217 |
} |
| 218 |
] |
| 219 |
} |
| 220 |
] |
| 221 |
} |
| 222 |
], |
| 223 |
"terminal": true |
| 224 |
} |
| 225 |
] |
| 226 |
} |
| 227 |
} |
| 228 |
} |
| 229 |
} |
| 230 |
} |