Baidu AI Cloud
中国站

百度智能云

CDN

Dynamic Acceleration Interface

Configure the Dynamic Acceleration Service EnableDsa/DisableDsa

Enabling/Disabling DSA refers to the open/close for user level.

cli := client.GetDefaultClient()      
                                      
//Enable DSA service                            
err := cli.EnableDsa()                
fmt.Printf("err:%+v\n", err)          
                                      
//Disable DSA service                            
err = cli.DisableDsa()                
fmt.Printf("err:%+v\n", err)          

Query the List of Dynamic Accelerated Domain Names ListDsaDomains

Query the list of a user’s domain names configured with DSA acceleration rules.

cli := client.GetDefaultClient()          
dsaDomains, err := cli.ListDsaDomains()   
fmt.Printf("dsaDomains:%+v\n", dsaDomains) 
fmt.Printf("err:%+v\n", err)              

dsaDomains is a string array, indicating the domain names configured with DSA acceleration rules.

Configure Dynamic Acceleration Rules for Domain Names SetDsaConfig

Configure the DSA acceleration rule of a domain name.

cli := client.GetDefaultClient()                   
testDomain := "test_go_sdk.baidu.com"              
                                                   
//Configure DSA rules                                         
err := cli.SetDsaConfig(testDomain, &api.DSAConfig{ 
	 Enabled: true,                                 
	 Rules: []api.DSARule{                          
	 	 {                                          
	 	 	 Type:  "suffix",                       
	 	 	 Value: ".mp4;.jpg;.php",               
	 	 },                                         
	 	 {                                          
	 	 	 Type:  "path",                         
	 	 	 Value: "/path",                        
	 	 },                                         
	 	 {                                          
	 	 	 Type:  "exactPath",                    
	 	 	 Value: "/path/to/file.mp4",            
	 	 },                                         
	 },                                             
	 Comment: "test",                               
})                                                 
fmt.Printf("err:%+v\n", err)                       
                                                   
//Cancel DSA rules                                         
err = cli.SetDsaConfig(testDomain, &api.DSAConfig{ 
	 Enabled: false,                                
})                                                 
fmt.Printf("err:%+v\n", err)                                               

api.DSAConfig is described as follows:

Field Type Description
Type string “suffix” means file type, “path” means dynamic path, and “exactPath” means dynamic URL.
Value string Configuration rules for the specified Type in “type”, separate multiple rules by “;”.
Previous
Cache Management Interface
Next
Statistical Interface (new version)