-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template Updates #8
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments. I do think the new comment format makes it less clear. No real opinion on the order of the functions. Moving backend names into constants is a good idea.
This makes a few minor stylistic changes to our `main.rs` template: * use builder to generate internal error response * describe error case in doc comment * move `main` to top of program * move valid methods array into `handle_request` * move backend constants to top, add docs
This PR removes the links in the documentation comments of `main` and `handle_request` in our template. While Rust documentation comments often include markdown links, this program template actually isn't a fantastic place to use this functionality. Most often, these comments will be viewed directly in the source code. Another important point against these is that neither of these functions are exported with `pub`. Consequentially, they won't show up in `cargo doc --open`. At best, they would appear in auto-completion dialogues in editors like VSCode, but this benefit isn't worth the impact to readability.
166ebef
to
3be792c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Template Changes
Here are some small changes to our template program. These are intended to address a few corners I've seen new users running into, namely: setting the correct backend name, and how users should handle errors in our application.
Overview
The most important changes are...
fastly
to version0.3.0
#[fastly::main]
procedural macro. (See: https://docs.rs/fastly/0.3.0/fastly/attr.main.html)"backend_name"
literals up to the top of the file, into documentedconst
values. This helps highlight the parts of our template that a user will always need to change, so people do not forget and run into cryptic hostcall error messages.main
documentation explaining that returning an error will result in a 500 Internal Server Error response being sent back to the client. I think this is a small conceptual detail that isn't explained clearly currently.Small Changes
A few other small changes made in the process of this PR:
VALID_METHODS
array into ourhandle_request
function. This was done to try and emphasize theBACKEND_NAME
consts, which must be changed for someone's service to work.