@marcel91200 / caddy Mirror · read-only
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 10, 23:45 UTC

master
go 22 lines 839 Bytes
Raw
1 package internal
2
3 import "fmt"
4
5 // MaxSizeSubjectsListForLog returns up to maxToDisplay keys from subjects.
6 // If any keys are omitted, it appends one additional entry summarising the
7 // omitted count. This bounds the number of subject names placed in the log
8 // while making truncation explicit.
9 func MaxSizeSubjectsListForLog(subjects map[string]struct{}, maxToDisplay int) []string {
10 numberOfNamesToDisplay := min(len(subjects), maxToDisplay)
11 domainsToDisplay := make([]string, 0, numberOfNamesToDisplay)
12 for domain := range subjects {
13 if len(domainsToDisplay) >= numberOfNamesToDisplay {
14 break
15 }
16 domainsToDisplay = append(domainsToDisplay, domain)
17 }
18 if len(subjects) > maxToDisplay {
19 domainsToDisplay = append(domainsToDisplay, fmt.Sprintf("(and %d more...)", len(subjects)-maxToDisplay))
20 }
21 return domainsToDisplay
22 }