Skip to content

Allow same route but different http method for route macros #1239

@Kayxue

Description

@Kayxue

Below code worked:

#[route("/home", method = post)]
pub async fn createHome(
    state: StateRef<'_, AppState>,
    body: LazyJson<HomeCU<'_>>,
) -> Result<Json<home::Model>, Error> {
//...
}

#[route("/home/getHomes", method = get)]
pub async fn getHomes(state: StateRef<'_, AppState>) -> Result<Json<Vec<home::Model>>, Error> {
//...
}

But if the code is like this, the program will panic:

#[route("/home", method = post)]
pub async fn createHome(
    state: StateRef<'_, AppState>,
    body: LazyJson<HomeCU<'_>>,
) -> Result<Json<home::Model>, Error> {
//...
}

#[route("/home", method = get)]         //<-- This line changed
pub async fn getHomes(state: StateRef<'_, AppState>) -> Result<Json<Vec<home::Model>>, Error> {
//...
}

Can you please make it no panic?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions