// doReg sends all types of registration requests.
// The type of request is identified by typ argument, which is a "resource"
// in the ACME spec terms.
//
// A non-nil acct argument indicates whether the intention is to mutate data
// of the Account. Only Contact and Agreement of its fields are used
// in such cases.
doReg sends all types of registration requests.
The type of request is identified by typ argument, which is a "resource"
in the ACME spec terms.

A non-nil acct argument indicates whether the intention is to mutate data
of the Account. Only Contact and Agreement of its fields are used
in such cases.
// doReg sends all types of registration requests . // The type of request is identified by typ argument which is a " resource " // in the ACME spec terms . // // A non - nil acct argument indicates whether the intention is to mutate data // of the Account . Only Contact and Agreement of its fields are used // in such cases .
func (c *Client) doReg(ctx context.Context, url string, typ string, acct *Account) (*Account, error) {
	req := struct {
		Resource  string   `json:"resource"`
		Contact   []string `json:"contact,omitempty"`
		Agreement string   `json:"agreement,omitempty"`
	}{
		Resource: typ,
	}
	if acct != nil {
		req.Contact = acct.Contact
		req.Agreement = acct.AgreedTerms
	}
	res, err := c.postJWS(ctx, c.Key, url, req)
	if err != nil {
		return nil, err
	}
	defer res.Body.Close()
	if res.StatusCode < 200 || res.StatusCode > 299 {
		return nil, responseError(res)
	}
	var v struct {
		Contact        []string
		Agreement      string
		Authorizations string
		Certificates   string
	}
	if err := json.NewDecoder(res.Body).Decode(&v); err != nil {
		return nil, fmt.Errorf("acme: invalid response: %v", err)
	}
	var tos string
	if v := linkHeader(res.Header, "terms-of-service"); len(v) > 0 {
		tos = v[0]
	}
	var authz string
	if v := linkHeader(res.Header, "next"); len(v) > 0 {
		authz = v[0]
	}
	return &Account{
		URI:            res.Header.Get("Location"),
		Contact:        v.Contact,
		AgreedTerms:    v.Agreement,
		CurrentTerms:   tos,
		Authz:          authz,
		Authorizations: v.Authorizations,
		Certificates:   v.Certificates,
	}, nil
}
func ( c * Client ) doReg ( ctx context . Context , url string , typ string , acct * Account ) ( * Account , error ) { req := struct { Resource string `json:"resource"` Contact [ ] string `json:"contact,omitempty"` Agreement string `json:"agreement,omitempty"` } { Resource : typ , } if acct != nil { req . Contact = acct . Contact req . Agreement = acct . AgreedTerms } res , err := c . postJWS ( ctx , c . Key , url , req ) if err != nil { return nil , err } defer res . Body . Close ( ) if res . StatusCode < 200 || res . StatusCode > 299 { return nil , responseError ( res ) } var v struct { Contact [ ] string Agreement string Authorizations string Certificates string } if err := json . NewDecoder ( res . Body ) . Decode ( & v ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } var tos string if v := linkHeader ( res . Header , " " ) ; len ( v ) > 0 { tos = v [ 0 ] } var authz string if v := linkHeader ( res . Header , " " ) ; len ( v ) > 0 { authz = v [ 0 ] } return & Account { URI : res . Header . Get ( " " ) , Contact : v . Contact , AgreedTerms : v . Agreement , CurrentTerms : tos , Authz : authz , Authorizations : v . Authorizations , Certificates : v . Certificates , } , nil }
doReg sends all types of registration requests.
doReg sends all types of registration requests .