mirror of
https://code.rocketnine.space/tslocum/gmitohtml.git
synced 2024-11-27 15:28:13 +01:00
Add LastRequestTime
This commit is contained in:
parent
72c8172ab8
commit
fb5e7f4ea4
2 changed files with 12 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
# gmitohtml
|
||||
[![GoDoc](https://gitlab.com/tslocum/godoc-static/-/raw/master/badge.svg)](https://docs.rocketnine.space/gitlab.com/tslocum/gmitohtml)
|
||||
[![GoDoc](https://gitlab.com/tslocum/godoc-static/-/raw/master/badge.svg)](https://docs.rocketnine.space/gitlab.com/tslocum/gmitohtml/pkg/gmitohtml)
|
||||
[![CI status](https://gitlab.com/tslocum/gmitohtml/badges/master/pipeline.svg)](https://gitlab.com/tslocum/gmitohtml/commits/master)
|
||||
[![Donate](https://img.shields.io/liberapay/receives/rocketnine.space.svg?logo=liberapay)](https://liberapay.com/rocketnine.space)
|
||||
|
||||
|
|
|
@ -9,8 +9,11 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var lastRequestTime = time.Now().Unix()
|
||||
|
||||
// Fetch downloads and converts a Gemini page.
|
||||
func fetch(u string, clientCertFile string, clientCertKey string) ([]byte, []byte, error) {
|
||||
if u == "" {
|
||||
|
@ -116,6 +119,9 @@ func handleIndex(writer http.ResponseWriter, request *http.Request) {
|
|||
|
||||
func handleRequest(writer http.ResponseWriter, request *http.Request) {
|
||||
defer request.Body.Close()
|
||||
|
||||
lastRequestTime = time.Now().Unix()
|
||||
|
||||
if request.URL == nil {
|
||||
return
|
||||
}
|
||||
|
@ -194,3 +200,8 @@ func StartDaemon(address string) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LastRequestTime returns the time of the last request.
|
||||
func LastRequestTime() int64 {
|
||||
return lastRequestTime
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue