PURGE FEATURE

This commit is contained in:
Andrea Spacca
2021-01-05 17:23:47 +01:00
parent 2721ece759
commit 6ac6c8fa99
5 changed files with 135 additions and 14 deletions

View File

@ -187,6 +187,14 @@ func RateLimit(requests int) OptionFn {
}
}
func Purge(days, interval int) OptionFn {
return func(srvr *Server) {
srvr.purgeDays = time.Duration(days) * time.Hour * 24
srvr.purgeInterval = time.Duration(interval) * time.Hour
}
}
func ForceHTTPs() OptionFn {
return func(srvr *Server) {
srvr.forceHTTPs = true
@ -280,6 +288,9 @@ type Server struct {
maxUploadSize int64
rateLimitRequests int
purgeDays time.Duration
purgeInterval time.Duration
storage Storage
forceHTTPs bool
@ -500,6 +511,10 @@ func (s *Server) Run() {
s.logger.Printf("---------------------------")
if s.purgeDays > 0 {
go s.purgeHandler()
}
term := make(chan os.Signal, 1)
signal.Notify(term, os.Interrupt)
signal.Notify(term, syscall.SIGTERM)