如何路由包含动态部分的请求。例如,我想要请求
import re
sr = "base | text1: 0.01 | text2: 0.02 | text3: 100.1"
pattern1 = r"^(\w+)((?:\s+\|\s+[\w\s]+\s*:\s*\d+\.\d+)+)$"
bases = re.findall (pattern1, sr)
for base in bases:
result = [base[0]]
pattern2 = r"\|\s+([\w\s]+)\s*:\s*(\d+\.\d+)"
texts = re.findall(pattern2, base[1])
for text in texts:
result.append(text[0])
result.append(text[1])
print (result)
将被路由到:
/v1/employees/{empid}/reports
此处/my/host/v1/employees/{empid}/reports
是动态的(字母数字),并随请求而变化。 {empid}
看起来将有助于匹配网址格式,但是如何将动态值传递给下游?