github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/endpoint_util.go (about)

     1  package openstack
     2  
     3  import (
     4  	"regexp"
     5  
     6  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     7  )
     8  
     9  // A regular expression used to verify whether or not contains a project id in an endpoint url
    10  var endpointProjectIdMatcher = regexp.MustCompile(`http[s]?://.+/(?:[V|v]\d+|[V|v]\d+\.\d+)/([a-z|A-Z|0-9]{32})(?:/|$)`)
    11  
    12  // ContainsProjectId detects whether or not the endpoint url contains a projectID
    13  func ContainsProjectId(endpointUrl string) bool {
    14  	return endpointProjectIdMatcher.Match([]byte(endpointUrl))
    15  }
    16  
    17  func StdRequestOpts() *golangsdk.RequestOpts {
    18  	return &golangsdk.RequestOpts{
    19  		MoreHeaders: map[string]string{"Content-Type": "application/json", "X-Language": "en-us"},
    20  	}
    21  }