-
Notifications
You must be signed in to change notification settings - Fork 4
feat/asseturl #71
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
feat/asseturl #71
Conversation
Reviewer's GuideThis PR introduces an File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Here's the code health analysis summary for commits Analysis Summary
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #71 +/- ##
==========================================
+ Coverage 91.28% 91.57% +0.29%
==========================================
Files 62 63 +1
Lines 2490 2541 +51
==========================================
+ Hits 2273 2327 +54
+ Misses 188 186 -2
+ Partials 29 28 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Hey @cnlangzi - I've reviewed your changes - here's some feedback:
- This PR includes refactoring of template function handling and changes to ETag generation alongside the main asset URL feature; consider splitting these into separate PRs.
- The default ETag algorithm was changed from MD5 to CRC32; ensure the increased risk of collisions with CRC32 is acceptable for caching purposes.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Pull Request Overview
This PR implements an asset URL feature that enhances static file handling by introducing asset URL generation with ETag and cache control. Key changes include updating the NewFileViewer signature and its usage across tests and view engines, enhancing static view engine file handling with asset URL support, and updating etag computation to use crc32.
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
viewer_file_test.go | Updated NewFileViewer calls to accommodate new parameters. |
viewer_file.go | Modified NewFileViewer and Render logic for etag and cache handling. |
viewengine_* | Adjusted Load and Reload method signatures to pass funcMap. |
option.go | Added new option functions for template functions and asset URL building. |
ext/* | Switched to using minified JS files and updated etag computation. |
etag.go | Changed etag computation from md5 to crc32. |
app.go and app_test.go | Updated app initialization to incorporate new asset URL handling and template function registration. |
Comments suppressed due to low confidence (1)
viewer_file.go:98
- [nitpick] The type assertion 'f.(io.ReadSeeker)' assumes that f implements io.ReadSeeker; it may be safer to check the type assertion to avoid potential panics if the file does not satisfy the interface.
http.ServeContent(w, r, v.path, fi.ModTime(), f.(io.ReadSeeker))
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.
Pull Request Overview
This PR implements the asset URL feature for static file handling by extending the file viewer and view engine APIs to support custom ETag and cache control parameters. Key changes include:
- Updating the NewFileViewer API and its callers across multiple files to include new etag and cache parameters.
- Refactoring template loading/reloading functions to require a function map, enabling more flexible template behavior.
- Introducing asset URL generation support and modifications in static asset and CSRF handling to use CRC32-based ETag computation.
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
viewer_file_test.go | Updated NewFileViewer calls for new parameters in test cases. |
viewer_file.go | Modified NewFileViewer signature and added cache header handling. |
viewengine_text.go | Updated template Load/Reload calls to include function map usage. |
viewengine_static.go | Added asset URL generation logic and cache control header support. |
viewengine_html.go | Adjusted template Reload/Load functions for function map usage. |
template_text_test.go | Updated tests to pass new function map parameters. |
template_text.go | Modified Load/Reload function signatures to include the function map. |
template_html.go | Updated to require function map parameter in Load/Reload methods. |
option.go | Added options for custom template functions and asset URL building. |
funcmap_test.go | New tests for function map validation (note potential client issue). |
ext/htmx and ext/csrf files | Updated JavaScript resource references and ETag computation to CRC32. |
app.go and app_test.go | Registered new asset URL function and updated tests accordingly. |
etag.go | Changed ETag computation from MD5 to CRC32-based hashing. |
Comments suppressed due to low confidence (2)
funcmap_test.go:45
- The variable 'client' is undefined. Replace 'client' with http.DefaultClient or use srv.Client() if available.
resp, err := client.Do(req)
app_test.go:854
- The variable 'client' is undefined. Replace 'client' with http.DefaultClient or use srv.Client() to execute the HTTP request.
resp, err := client.Do(req)
Changed
Fixed
Added
asseturl
featureTests
Tasks to complete before merging PR:
make unit-tests
to check for any regressions 📋make lint
to check for any issuesSummary by Sourcery
Implement asset URL feature with enhanced static file handling and caching
New Features:
Enhancements:
Chores: