update docs to explain intended pattern for common code (#58)#78
Merged
davepacheco merged 2 commits intooxidecomputer:masterfrom Jan 19, 2021
Merged
update docs to explain intended pattern for common code (#58)#78davepacheco merged 2 commits intooxidecomputer:masterfrom
davepacheco merged 2 commits intooxidecomputer:masterfrom
Conversation
ahl
approved these changes
Jan 19, 2021
Collaborator
ahl
left a comment
There was a problem hiding this comment.
typo (I think?) and a very mild suggestion that you should feel free to reject
|
|
||
| With Dropshot, we wanted to try something different: if the primary purpose of these handlers is to share code between handlers, what if we rely instead on existing mechanisms -- i.e., function calls. The big risk is that it's easy for someone to accidentally forget some important function call, like the one that authentices or authorizes a user. We haven't gotten far enough in a complex implementation to need this yet, but the plan is to create a pattern of utility functions that return typed values. For example, where in Node.js you might add an early authentication handler that fills in `request.auth`, with Dropshot you'd have an authentication function that _returns_ an `AuthzContext` struct. Then anything that needs authentication consumes the `AuthzContext` as a function argument. As an author of a handler, you know if you've got an `AuthzContext` available and, if not, how to get one (call the utility function). This composes, too: you can have an authorization function that returns an `AuthnContext`, and the utility function that returns one can consume the `AuthzContext`. Then anything that requires authorization can consume just the `AuthnContext`, and you know it's been authenticated and authorized (possibly with details in that structure). | ||
|
|
||
| It's early, and we may find we need richer facilities in the framework. But we're hopeful this approach will make it faster and smoother to iterate on complex API servers. |
Collaborator
There was a problem hiding this comment.
Suggested change
| It's early, and we may find we need richer facilities in the framework. But we're hopeful this approach will make it faster and smoother to iterate on complex API servers. | |
| It's early, and we may find we need richer facilities in the framework. But we're hopeful this approach will make it faster and smoother to iterate on complex API servers. We welcome feedback from folks using or interested in using Dropshot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #58.