Create Route
POST {{gateway}}/routes
Create Route konghq
- See also konghq
Request Body
Attributes | Mandatory | Description |
---|---|---|
name | optional | The Route name |
protocols | required | A list of the protocols this Route should allow. When set to ["https"], HTTP requests are answered with a request to upgrade to HTTPS. Defaults to ["http", "https"] |
methods | semi-optional | A list of HTTP methods that match this Route |
hosts | semi-optional | A list of domain names that match this Route. With form-encoded, the notation is hosts[]=example.com&hosts[]=foo.test. With JSON, use an Array. |
paths | semi-optional | A list of paths that match this Route. With form-encoded, the notation is paths[]=/foo&paths[]=/bar. With JSON, use an Array. |
headers | semi-optional | One or more lists of values indexed by header name that will cause this Route to match if present in the request. The Host header cannot be used with this attribute: hosts should be specified using the hosts attribute. |
https_redirect_status_code | required | The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS. Location header is injected by Kong if the field is set to 301, 302, 307 or 308. Accepted values are: 426, 301, 302, 307, 308. Defaults to 426. |
regex_priority | optional | A number used to choose which route resolves a given request when several routes match it using regexes simultaneously. When two routes match the path and have the same regex_priority, the older one (lowest created_at) is used. Note that the priority for non-regex routes is different (longer non-regex routes are matched before shorter ones). Defaults to 0. |
strip_path | optional | When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Defaults to true. |
path_handling | optional | Controls how the Service path, Route path and requested path are combined when sending a request to the upstream. See above for a detailed description of each behavior. Accepted values are: "v0", "v1". Defaults to "v0". |
preserve_host | optional | When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host. |
snis | semi-optional | A list of SNIs that match this Route when using stream routing. |
sources | semi-optional | A list of IP sources of incoming connections that match this Route when using stream routing. Each entry is an object with fields “ip” (optionally in CIDR range notation) and/or “port”. |
preserve_host | optional | When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host. |
destinations | semi-optional | A list of IP destinations of incoming connections that match this Route when using stream routing. Each entry is an object with fields “ip” (optionally in CIDR range notation) and/or “port”. |
tags | optional | An optional set of strings associated with the Route, for grouping and filtering. |
service | optional | The Service this Route is associated to. This is where the Route proxies traffic to. With form-encoded, the notation is service.id= |
Request Body
{"name"=>"httpbin-api", "url"=>"https://httpbin.org/"}
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
Content-Type | string |
RESPONSES
status: Created
{"id":"875973fd-ba3f-4c7b-8301-e9263013e6d2","path_handling":"v0","paths":["/foo","/bar"],"destinations":null,"headers":{"x-another-header":["bla"],"x-my-header":["foo","bar"]},"protocols":["http","https"],"methods":["GET","POST"],"snis":null,"service":{"id":"c8b8f724-7e73-4df6-b1a8-8df19642d388"},"name":"my-route","strip_path":true,"preserve_host":false,"regex_priority":0,"updated_at":1583977879,"sources":null,"hosts":["example.com","foo.test"],"https_redirect_status_code":426,"tags":["user-level","low-priority"],"created_at":1583977879}