m-cloud API Documentation - v1.0.1-beta.5
    Preparing search index...

    Function createRouteMatch

    • 创建路由匹配函数 根据匹配选项生成路由匹配函数,支持缓存

      Parameters

      • Optionaloptions: MatchOptions

        匹配选项

      Returns MatchFn

      路由匹配函数

      当同时指定 match 和 ignore 时抛出异常

      // 匹配所有路由
      const matchFn = createRouteMatch()

      // 匹配特定路由
      const matchFn = createRouteMatch({ match: 'user' })

      // 使用正则表达式匹配
      const matchFn = createRouteMatch({ match: /^user/ })

      // 忽略特定路由
      const matchFn = createRouteMatch({ ignore: 'health' })

      // 使用自定义匹配函数
      const matchFn = createRouteMatch({ match: (ctx) => ctx.event.action === 'user' })