Closed petersalomonsen closed 6 months ago
The update enhances web request handling in a Rust application by introducing the web4
module. This includes new types for managing web requests and responses, a handler for dynamic HTML content creation based on request paths, and the addition of the html-escape
dependency for HTML processing. The web4
module is now publicly accessible with a specific function web4_get
for fetching web content.
File | Changes |
---|---|
Cargo.toml |
Added html-escape dependency version 0.2.13 . |
src/lib.rs |
Added web4 module to public exports, imported relevant types, and included web4_get function. |
src/web4/handler.rs |
Introduced handler.rs with web request handling functionality, including web4_get . |
🐇✨ In the code's meadow, under the bright moon, A new module blooms, none too soon. Web4 dances, with requests it plays, Crafting HTML in wondrous ways. Cheers to the coders, with each line they write, In Rust we trust, by day and night. 🌟 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
This PR adds the
web4_get
method to the contract, so that when merged, there will be a website at https://devhub.near.pageYou can preview it at https://devhublink.testnet.page/
Note that the preview deployment does not have access to content, so it will not be able to display proper content for preview links, which is provided by the contract. A test community "webassemblymusic" is created for the preview deployment, to demonstrate the preview links. You can test it at https://devhublink.testnet.page/community/webassemblymusic. You may also call the preview contract to create proposals and other communities to verify that social media headers are also populated with the content.
For now the first part of the part is always mapped to the
page
property, so that e.g./proposals
are translated to/devhub.near/widget/app?page=proposals
. Also the second part translates tohandle
for community (/community/webassemblymusic
->/devhub.near/widget/app?page=community&handle=webassemblymusic
), or toid
for proposal/proposal/5
->/devhub.near/widget/app?page=proposal&id=5
In addition to metadata for social media links, and SEO friendly URLs, the actual content is viewed as well. This is done using near-bos-webcomponent which is also used for playwright tests in the DevHub frontend. A PR have also been created there to support the SEO friendly URL paths created here.
The
html-escape
crate is added to ensure that descriptions with html tags are escaped for the generated HTML ( to avoid malicious scripts etc ).Examples:
Part of https://github.com/NEAR-DevHub/neardevhub-bos/issues/724
Summary by CodeRabbit
New Features
web4
module to handle web requests, dynamically generate HTML content, and encode responses.Documentation
Dependencies
html-escape
library to support HTML content generation.