dropbox / dropbox/stone

Dependent routes/data structures?

Open
#112 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
413
Forks
81
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.