Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 11, 01:00 UTC
| 1 | :80 { |
| 2 | @books url_pattern /books/:id |
| 3 | respond @books "book {http.url_pattern.pathname.id}" |
| 4 | |
| 5 | @scoped url_pattern /api/:version/* { |
| 6 | base_url https://example.com |
| 7 | ignore_case |
| 8 | } |
| 9 | respond @scoped "scoped" |
| 10 | |
| 11 | @absolute url_pattern https://example.com/users/:name |
| 12 | respond @absolute "user {http.url_pattern.pathname.name}" |
| 13 | } |
| 14 | ---------- |
| 15 | { |
| 16 | "apps": { |
| 17 | "http": { |
| 18 | "servers": { |
| 19 | "srv0": { |
| 20 | "listen": [ |
| 21 | ":80" |
| 22 | ], |
| 23 | "routes": [ |
| 24 | { |
| 25 | "match": [ |
| 26 | { |
| 27 | "url_pattern": { |
| 28 | "pattern": "/books/:id" |
| 29 | } |
| 30 | } |
| 31 | ], |
| 32 | "handle": [ |
| 33 | { |
| 34 | "body": "book {http.url_pattern.pathname.id}", |
| 35 | "handler": "static_response" |
| 36 | } |
| 37 | ] |
| 38 | }, |
| 39 | { |
| 40 | "match": [ |
| 41 | { |
| 42 | "url_pattern": { |
| 43 | "pattern": "/api/:version/*", |
| 44 | "base_url": "https://example.com", |
| 45 | "ignore_case": true |
| 46 | } |
| 47 | } |
| 48 | ], |
| 49 | "handle": [ |
| 50 | { |
| 51 | "body": "scoped", |
| 52 | "handler": "static_response" |
| 53 | } |
| 54 | ] |
| 55 | }, |
| 56 | { |
| 57 | "match": [ |
| 58 | { |
| 59 | "url_pattern": { |
| 60 | "pattern": "https://example.com/users/:name" |
| 61 | } |
| 62 | } |
| 63 | ], |
| 64 | "handle": [ |
| 65 | { |
| 66 | "body": "user {http.url_pattern.pathname.name}", |
| 67 | "handler": "static_response" |
| 68 | } |
| 69 | ] |
| 70 | } |
| 71 | ] |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | } |