-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: change default proxy.conf #8971
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,12 @@ func CheckSecurity(c *gin.Context) bool { | |
| func ToIndexHtml(c *gin.Context) { | ||
| c.Writer.Header().Set("Content-Type", "text/html; charset=utf-8") | ||
| c.Writer.WriteHeader(http.StatusOK) | ||
| _, _ = c.Writer.Write(web.IndexByte) | ||
| data, err := web.IndexHtml.ReadFile("index.html") | ||
| if err != nil { | ||
| c.String(http.StatusInternalServerError, "index.html not found") | ||
| return | ||
| } | ||
| _, _ = c.Writer.Write(data) | ||
| c.Writer.Flush() | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes you've made seem largely correct, although there is a small issue with the return type of Here's your updated code: func ToIndexHtml(c *gin.Context) {
c.Writer.Header().Set("Content-Type", "text/html; charset=utf-8")
c.Writer.WriteHeader(http.StatusOK)
data, err := web.IndexHtml.ReadFile("index.html")
if err != nil {
c.String(http.StatusInternalServerError, "index.html not found")
return
}
_, _ = c.Writer.Write(data)
c.Writer.Flush()
}Potential Improvements:
These enhancements ensure better robustness and performance of the function. |
||
|
|
||
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.
There is no apparent issue with the provided code. Here are some minor improvements for better clarity:
These two lines can be merged for cleaner syntax while maintaining the same functionality. It's a matter of preference and style choice.
Note: The
IndexBytevariable was removed because embedding multiple files of the same name within an embed directive results in only one file being embedded and accessible via that name. If you were to includeindex.htmlseparately later on, it would conflict with this single entry under "assets".If preserving both versions (
Assetsfor other HTML files andIndexBytefor a specific index.html) is necessary, you don't need to remove anything - they simply share different names but contain the same set of files.