Skip to content

web/landing_page: Add option to disable profiling links #328

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions web/landing_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type LandingConfig struct {
ExtraHTML string // Additional HTML to be embedded.
ExtraCSS string // Additional CSS to be embedded.
Version string // The version displayed.
Profiling string // If false, don't display profiling links.
}

// LandingForm provides a configuration struct for creating a POST form on the landing page.
Expand Down Expand Up @@ -103,6 +104,10 @@ func NewLandingPage(c LandingConfig) (*LandingPageHandler, error) {
} else if !strings.HasSuffix(c.RoutePrefix, "/") {
c.RoutePrefix += "/"
}

if c.Profiling == "" {
c.Profiling = "true"
}
// Strip leading '/' from Links if present
for i, link := range c.Links {
c.Links[i].Address = strings.TrimPrefix(link.Address, "/")
Expand Down
2 changes: 2 additions & 0 deletions web/landing_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h1>{{.Name}}</h1>
</div>
{{ end }}
{{ .ExtraHTML }}
{{ if eq .Profiling "true" }}
<div id="pprof">
Download a detailed report of resource usage (pprof format, from the Go runtime):
<ul>
Expand All @@ -38,6 +39,7 @@ <h1>{{.Name}}</h1>
</ul>
To visualize and share profiles you can upload to <a href="https://pprof.me" target="_blank" rel="noopener noreferrer">pprof.me</a>
</div>
{{ end }}
</main>
</body>
</html>