| 1428 | } |
| 1429 | |
| 1430 | func matcherSetFromMatcherToken( |
| 1431 | tkn caddyfile.Token, |
| 1432 | matcherDefs map[string]caddy.ModuleMap, |
| 1433 | warnings *[]caddyconfig.Warning, |
| 1434 | ) (caddy.ModuleMap, bool, error) { |
| 1435 | // matcher tokens can be wildcards, simple path matchers, |
| 1436 | // or refer to a pre-defined matcher by some name |
| 1437 | if tkn.Text == "*" { |
| 1438 | // match all requests == no matchers, so nothing to do |
| 1439 | return nil, true, nil |
| 1440 | } |
| 1441 | |
| 1442 | // convenient way to specify a single path match |
| 1443 | if strings.HasPrefix(tkn.Text, "/") { |
| 1444 | return caddy.ModuleMap{ |
| 1445 | "path": caddyconfig.JSON(caddyhttp.MatchPath{tkn.Text}, warnings), |
| 1446 | }, true, nil |
| 1447 | } |
| 1448 | |
| 1449 | // pre-defined matcher |
| 1450 | if strings.HasPrefix(tkn.Text, matcherPrefix) { |
| 1451 | m, ok := matcherDefs[tkn.Text] |
| 1452 | if !ok { |
| 1453 | return nil, false, fmt.Errorf("unrecognized matcher name: %+v", tkn.Text) |
| 1454 | } |
| 1455 | return m, true, nil |
| 1456 | } |
| 1457 | |
| 1458 | return nil, false, nil |
| 1459 | } |
| 1460 | |
| 1461 | func (st *ServerType) compileEncodedMatcherSets(sblock serverBlock) ([]caddy.ModuleMap, error) { |
| 1462 | type hostPathPair struct { |