Include time taken to render in footer
This commit is contained in:
parent
7fefb689c7
commit
733aa237d1
4 changed files with 17 additions and 1 deletions
|
|
@ -37,10 +37,21 @@ type RuntimeFlags struct {
|
|||
|
||||
RequestURI string // request uri of the current page
|
||||
Menu []component.MenuItem // menu at the top of the page
|
||||
StartedAt time.Time // time the request started to generate
|
||||
GeneratedAt time.Time // time the underlying data returned
|
||||
CSRF template.HTML // csrf data (if any)
|
||||
}
|
||||
|
||||
// Returns how long this request took to render
|
||||
func (rf RuntimeFlags) Took() time.Duration {
|
||||
return time.Since(rf.StartedAt)
|
||||
}
|
||||
func (rf RuntimeFlags) TookHTML() template.HTML {
|
||||
took := rf.Took()
|
||||
|
||||
return template.HTML(fmt.Sprintf("<time datetime=\"P%.3f\">%s</time>", took.Seconds(), took))
|
||||
}
|
||||
|
||||
var runtimeFlagsName = reflectx.TypeFor[RuntimeFlags]().Name()
|
||||
|
||||
// Clone clones this flags
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue