Rewrite
少于1分钟
Rewrite 重写
Rewrite middleware rewrites the URL path based on provided rules. It can be helpful for backward compatibility or just creating cleaner and more descriptive links.
重写中间件根据提供的规则重写 URL 路径。它有助于向后兼容或只是创建更简洁、更具描述性的链接。
Signatures 签名
|
|
Config 配置
Property 属性 | Type 输入 | Description 说明 | Default 默认 |
---|---|---|---|
Next 下一步 | func(*fiber.Ctx) bool | Next defines a function to skip middleware. 接下来定义一个跳过中间件的函数。 | nil |
Rules 规则 | map[string]string | Rules defines the URL path rewrite rules. The values captured in asterisk can be retrieved by index. 规则定义 URL 路径重写规则。星号中捕获的值可以通过索引检索。 | (Required) (必需) |
Examples 示例
|
|
Test: 测试:
curl http://localhost:3000/old
curl http://localhost:3000/old/hello