@@ -27,11 +27,11 @@ func Info(c *drycc.Client, app string) (api.TLS, error) {
2727 return tls , reqErr
2828}
2929
30- // Enable enables the router to enforce https-only requests to the application.
31- func Enable (c * drycc.Client , app string ) (api.TLS , error ) {
30+ // changeTLS enables the router to enforce https-only requests to the application.
31+ func changeTLS (c * drycc.Client , app string , httpsEnforced , certsAutoEnabled * bool ) (api.TLS , error ) {
3232 t := api .NewTLS ()
33- b := true
34- t .HTTPSEnforced = & b
33+ t . HTTPSEnforced = httpsEnforced
34+ t .CertsAutoEnabled = certsAutoEnabled
3535 body , err := json .Marshal (t )
3636
3737 if err != nil {
@@ -54,26 +54,26 @@ func Enable(c *drycc.Client, app string) (api.TLS, error) {
5454 return newTLS , reqErr
5555}
5656
57- // Disable disables the router from enforcing https-only requests to the application.
58- func Disable (c * drycc.Client , app string ) (api.TLS , error ) {
59- body , err := json .Marshal (api .NewTLS ())
60-
61- if err != nil {
62- return api.TLS {}, err
63- }
64-
65- u := fmt .Sprintf ("/v2/apps/%s/tls/" , app )
57+ // EnableHTTPSEnforced enables the router to enforce https-only requests to the application.
58+ func EnableHTTPSEnforced (c * drycc.Client , app string ) (api.TLS , error ) {
59+ b := true
60+ return changeTLS (c , app , & b , nil )
61+ }
6662
67- res , reqErr := c . Request ( "POST" , u , body )
68- if reqErr != nil {
69- return api. TLS {}, reqErr
70- }
71- defer res . Body . Close ()
63+ // DisableHTTPSEnforced disables the router from enforcing https-only requests to the application.
64+ func DisableHTTPSEnforced ( c * drycc. Client , app string ) (api. TLS , error ) {
65+ b := false
66+ return changeTLS ( c , app , & b , nil )
67+ }
7268
73- newTLS := api.TLS {}
74- if err = json .NewDecoder (res .Body ).Decode (& newTLS ); err != nil {
75- return api.TLS {}, err
76- }
69+ // EnableCertsAutoEnabled enables ACME to automatically generate certificates.
70+ func EnableCertsAutoEnabled (c * drycc.Client , app string ) (api.TLS , error ) {
71+ b := true
72+ return changeTLS (c , app , nil , & b )
73+ }
7774
78- return newTLS , reqErr
75+ // DisableCertsAutoEnabled disables ACME to automatically generate certificates.
76+ func DisableCertsAutoEnabled (c * drycc.Client , app string ) (api.TLS , error ) {
77+ b := false
78+ return changeTLS (c , app , nil , & b )
7979}
0 commit comments