Skip to content

One url make 2 action call #220

Closed
Closed
@soulski

Description

@soulski

Hi, I have one Controller which have 2 method like below

import { JsonController, Get } from 'routing-controllers'

@JsonController('/api')
export class APIController {

    @Get('/user')
    public getByUser() {
        console.log('output2')
        return Promise.resolve({ say: 'user' })
    }

    @Get('/:id')
    public getById() {
        console.log('output1')
        return Promise.resolve({ say: 'hello1' })
    }

}

I run server and then send http request in path '/user'. The result in console log print follow below

output1
output2

and I receive response as json { say: 'user' }. I take a look at source code and found that after action was called, routing-controller call next method which I suspect it is the reason why 2 action which match path url call. I test by insert after after middleware that didn't call next. The result is only getByUser was called. Is this intend behavior? It use invoke only getByUser, is't it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: fixedIssues with merged PRs, but not released yet.type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions