Skip to content

Dependent routes/data structures? #112

@elefthei

Description

@elefthei

Is there a way to indicate dependencies between routes? For example very often, visiting /login is required before /logout.

There could also be dependencies between data, let's say you have:

alias UUID = String(pattern="[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}")

struct RegisterReq
    "Describes a user registration request, this is often required to do anything else."

    username String
        "Given username for that user."

struct RegisterResp
    "Describes a registration response, indicates a user has registered and is now identifiable"

    uuid UUID
        "A universal identifier"

struct LogoutReq
    "Triggers the user to logout, requires a UUID to have been received"

    @Depends(RegisterResp)
    uuid UUID

route register_person(RegisterReq, RegisterResp, Void)
route logout_person(LogoutReq, Void, Void)

I think dependency semantics are very useful when testing routes, so if there's no semanics in place right now, I'd like to propose a @Depends annotation for dependant datatypes, from which we can infer the natural order of requests, used as seen above.

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