func (m *cert) Put(w http.ResponseWriter, req *http.Request) (string, error) {
	distribute, _ := strconv.ParseBool(req.URL.Query().Get("distribute"))
	if distribute {
		return "", m.sendDistributeRequests(w, req)
	}
	certName, certContent, err := m.getCertFromRequest(w, req)
	if err != nil {  
		m.writeError(w, err)
		return "", err
	}
	path, err := m.PutCert(certName, certContent)
	if err != nil {
		m.writeError(w, err)
		return "", err
	}
	proxy.Instance.CreateConfigFromTemplates()
	proxy.Instance.Reload()
	msg := CertResponse{Status: "OK", Message: ""}
	m.writeOK(w, msg)
	return path, nil
}
Put adds a certificate to the proxy.
If a certificate with the same name already exists, it will be overwritten by the new certificate.
package server
import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net"
	"net/http"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"sync"
	"time"
	"github.com/docker-flow/docker-flow-proxy/proxy"
)
var mu = &sync.Mutex{}
type Certer interface {
	Put(w http.ResponseWriter, req *http.Request) (string, error)
	PutCert(certName string, certContent []byte) (string, error)
	GetAll(w http.ResponseWriter, req *http.Request) (CertResponse, error)
	Init() error
}
type cert struct {
	ServicePort      string
	ProxyServiceName string
	CertsDir         string
	CertContent      string
}
type CertResponse struct {
	Status  string
	Message string
	Certs   []cert
}
func (m *cert) GetAll(w http.ResponseWriter, req *http.Request) (CertResponse, error) {
	pCerts := proxy.Instance.GetCerts()
	certs := []cert{}
	for path, content := range pCerts {
		if !strings.HasPrefix(path, "/run/secrets") {
			parts := strings.Split(path, "/")
			cert := cert{CertContent: content}
			nameIndex := len(parts) - 1
			for index, part := range parts {
				if index == nameIndex {
					cert.ProxyServiceName = part
				} else if len(part) > 0 {
					cert.CertsDir += "/" + part
				}
			}
			certs = append(certs, cert)
		}
	}
	msg := CertResponse{Status: "OK", Message: "", Certs: certs}
	m.writeOK(w, msg)
	return msg, nil
}
func (m *cert) PutCert(certName string, certContent []byte) (string, error) {
	return m.writeFile(certName, certContent)
}