-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtls.go
More file actions
46 lines (42 loc) · 1.55 KB
/
tls.go
File metadata and controls
46 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package api
import (
"fmt"
)
// TLS is the structure of an app's TLS settings.
type TLS struct {
// Owner is the app owner. It cannot be updated with TLS.Set(). See app.Transfer().
Owner string `json:"owner,omitempty"`
// App is the app the tls settings apply to and cannot be updated.
App string `json:"app,omitempty"`
// Created is the time that the TLS settings was created and cannot be updated.
Created string `json:"created,omitempty"`
// Updated is the last time the TLS settings was changed and cannot be updated.
Updated string `json:"updated,omitempty"`
// UUID is a unique string reflecting the TLS settings in its current state.
// It changes every time the TLS settings is changed and cannot be updated.
UUID string `json:"uuid,omitempty"`
//HTTPSEnforced determines if the router should enable or disable https-only requests.
HTTPSEnforced *bool `json:"https_enforced,omitempty"`
//Use ACME to automatically generate certificates if CertsAuto enable
CertsAutoEnabled *bool `json:"certs_auto_enabled,omitempty"`
}
// NewTLS creates a new TLS object with fields properly zeroed
func NewTLS() *TLS {
return &TLS{
HTTPSEnforced: new(bool),
CertsAutoEnabled: new(bool),
}
}
func (t TLS) String() string {
tpl := `HTTPS Enforced: %s
Certs Auto: %s`
httpsEnforced := "not set"
if t.HTTPSEnforced != nil {
httpsEnforced = fmt.Sprintf("%t", *(t.HTTPSEnforced))
}
certsAutoEnabled := "not set"
if t.CertsAutoEnabled != nil {
certsAutoEnabled = fmt.Sprintf("%t", *(t.CertsAutoEnabled))
}
return fmt.Sprintf(tpl, httpsEnforced, certsAutoEnabled)
}