【问题标题】:Issue with pattern matching of urls in seneca when hierarchy is the same当层次结构相同时,seneca 中 url 的模式匹配问题
【发布时间】:2017-06-02 02:16:50
【问题描述】:

我有 2 个网址,例如:

  1. /测试/运行
  2. /test/{test_id}

我有 2 条单独的路线供他们使用,例如:

1. {
prefix: '/test',
pin: 'role:test,cmd:*',
map:{
run: {GET: true}
}
}

2. {
pin: 'role:test,cmd:*',
map:{
test: {GET: true, suffix: '/:test_id'} 
} 
}

但是当我访问 /test/run.第二种模式通过作为 URL 参数运行来触发。

这是预期的行为还是有其他方法可以做到这一点?

【问题讨论】:

    标签: javascript express seneca


    【解决方案1】:

    你必须设置不同的模式( 否则 seneca 将无法区分它们)

    别针

    对于带有seneca.use('role:web', {..}) 和操作seneca.act('role:test,cmd:test,action:byId', (..)=>{..}) 的seneca 插件

    {
     prefix: '/test',
     pin: 'role:test,cmd:*',
     map:{
     run: {GET: true}
    }
    
    {
     prefix: '/test',
     pin: 'role:test,cmd:*,action:byId',
     map:{
     test: {GET: true, suffix: '/:test_id'} 
    } 
    

    【讨论】:

    • 嗨@Shobhit Srivastava,我的回答是否满足了您的问题? :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    • 2023-02-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 2015-05-12
    • 1970-01-01
    相关资源
    最近更新 更多