[path to advanced API] because I can’t create a cloud server, I’m set up by interns

Time:2020-11-27

Abstract:Nine steps to create cloud server through API.

The thing is, the company set up a new project, to build an official website for the project, and build a web server. According to my habit, it’s good to build a local virtual machine. It’s easy to deploy and configure. The cloud server, after 10 years of code writing, is still not used to it.

As soon as I started, I saw the interns running over. I thought that this boy must want to learn how to build and deploy virtual machines. I can’t do such a simple thing. I’m really blind to his 985 school.

But… I didn’t expect that, the little intern went to my boss to ask for credit!!! From afar, he said: “the company’s new projects are running on the cloud server. In the future, it can be expanded flexibly at any time according to the number of visits. It is safe, stable and fast.”

What? Cloud server? How can this kid configure the cloud server? After listening to the report, the boss looked at me and brought the intern to me

“Hum, I told you to take credit and hit the gun. I said that the configuration of cloud server is not so easy, and I still have to come to me ~” I was a little proud of that. The boss came over and patted me on the shoulder and said, “learn from him how to configure cloud servers. Don’t use virtual machines any more. It will be troublesome in the future.”

I… he… Let me learn from an intern???

The intern gave me a smile and left. After a while, the intern threw me a document, which said: “details of creating elastic cloud server process”. Open a cursory glance, the code is directly pasted up? Who do you look down on? I feel offended.

Technical person, see the code still can’t resist to run again, wait for me to discover bug or can’t run, teach him again!

First get a free cloud server, and then start running code

As a result It’s delicious.

The content is as follows:

9 steps of creating cloud server through API (taking creating cloud server in specified image mode as an example)

Step 1: determine the availability zone of the cloud server to be created.

1. Query availability zone.

(1) Interface related information

Uri format: get / v2.1 / {project_ id}/os-availability-zone

(2) Request example

GET: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/os-availability-zone

(3) Response examples

 {
  "availabilityZoneInfo": [
    {
      "hosts": null,
      "zoneState": {
        "available": true
      },
      "zoneName":"zone_01" 
    },
    {
      "hosts": null,
      "zoneState": {
        "available": true
      },
      "zoneName": "zone_01" 
    }
  ]
}

2. Select the zone according to the actual needs and record the zonename of the zone.

Step 2: determine the specifications of the cloud server to be created.

1. Query the ECS specification information.

(1) Interface related information

Uri format: get / v2.1 / {project_ id}/flavors/detail{?minDisk,minRam,is_ public,sort_ key,sort_ dir}

The field after “?” is the optional query retrieval parameter for query specification.

(2) Request example

GET: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/flavors/detail

(3) Response examples

{
  "flavors": [
    {
      "name": "c1.2xlarge",
      "links": [
        {
          "href": "https://xxx/v2.1/74610f3a5ad941998e91f076297ecf27/flavors/c1.2xlarge",
          "rel": "self"
        },
        {
          "href": "https://xxx/74610f3a5ad941998e91f076297ecf27/flavors/c1.2xlarge",
          "rel": "bookmark"
        }
      ],
      "ram": 8192,
      "OS-FLV-DISABLED:disabled": false,
      "vcpus": 8,
      "swap": "",
      "os-flavor-access:is_public": true,
      "rxtx_factor": 1,
      "OS-FLV-EXT-DATA:ephemeral": 0,
      "disk": 0,
      "id": "c1.2xlarge"
    }
]
}

2. Select the specification according to the actual needs and record the ID of the specification.

Step 3: determine the image to be used by the cloud server to be created.

1. Query image.

(1) Interface related information

Uri format: get / v2.1 / {project_ id}/images/detail

(2) Request example

GET: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/images/detail

(3) Response examples

{
  "images": [
    {
      "OS-EXT-IMG-SIZE:size": 0,
      "metadata": {
        "__os_type": "Linux",
        "hw_vif_multiqueue_enabled": "true",
        "__imagetype": "gold",
        "__quick_start": "true",
        "virtual_env_type": "FusionCompute",
        "__support_xen": "true",
        "__support_kvm": "true",
        "__image_source_type": "uds",
        "__platform": "EulerOS",
        "__os_version": "EulerOS 2.2 64bit",
        "__os_bit": "64",
        "__isregistered": "false"
      },
      "created": "2018-05-14T06:13:50Z",
      "minRam": 0,
      "name": "DBS-MySQL-Image_2.1.3.3",
      "progress": 100,
      "links": [
        {
          "rel": "self",
          "href": "https://None/v2.1/74610f3a5ad941998e91f076297ecf27/images/11e8f727-d439-4ed1-b3b8-33f46c0379c4"
        },
        {
          "rel": "bookmark",
          "href": "https://None/74610f3a5ad941998e91f076297ecf27/images/11e8f727-d439-4ed1-b3b8-33f46c0379c4"
        },
        {
          "rel": "alternate",
          "href": "https://None/images/11e8f727-d439-4ed1-b3b8-33f46c0379c4",
          "type": "application/vnd.openstack.image"
        }
      ],
      "id": "11e8f727-d439-4ed1-b3b8-33f46c0379c4",
      "updated": "2018-05-14T06:13:52Z",
      "minDisk": 40,
      "status": "ACTIVE"
    }
  ]
}

2. Select the image as needed and record the image ID.

Step 4: determine the network information of the cloud server.

1. Check the network.

(1) Interface related information

Uri format: get / v2.1 / {project_ id}/os-networks

(2) Request example

GET: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/os-networks

(3) Response examples

{
  "networks": [
    {
      "id": "07a9557d-4256-48ae-847c-415a9c8f7ff6",
      "label": "b_tt3_td1b",
      "broadcast": null,
      "cidr": null,
      "dns1": null,
      "dns2": null,
      "gateway": null,
      "netmask": null,
      "cidr_v6": null,
      "gateway_v6": null,
      "netmask_v6": null
    }
  ]
}

2. Select the network as needed and record the network ID.

Step 5: set the key pair login mode.

To set the password login mode, please go to step 7 directly.

1. Create a key pair.

(1) Interface related information

Uri format: post / v2.1 / {project_ id}/os-keypairs

(2) Request example

POST: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/os-keypairs

Body:

{
    "keypair": {
        "type": "ssh",
        "name": "demo1",
        "user_id": "fake"
    }
}

(3) Response examples

{
  "keypair": {
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrR5Gcwlh5ih7JOvzIUuQxS5qzWWPMYHeDXkDKSQ9W5pumOV05SiO3WCswnaQ5xMdOl31mNiHtwlwq9dJi7X6jJBB2shTD+00G5WuwkBbFU4CLvt1B44u0NUiaTJ35NAvW2/4XvpXm9OwiQ3B5ge6ZY7Esi38Unh+pkbhPkYxNBCK8yoOlojQhWs75abdxZBi811/8RwLcNiFiocA2RGxtRjBdpEScj+1TU+OcfZdQnr0AFbO11z7yxfIygwwzVTgUuJNbMbKHStQqRbklfMlHY4RBPQgb7RN/YaXKTQSXT84k+D9xlDNo7Wj4fwOJTOz/s/PvbIOqjRHt9D6Y4IKd Generated-by-Nova\n",
    "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAq0eRnMJYeYoeyTr8yFLkMUuas1ljzGB3g15AykkPVuabpjld\nOUojt1grMJ2kOcTHTpd9ZjYh7cJcKvXSYu1+oyQQdrIUw/tNBuVrsJAWxVOAi77d\nQeOLtDVImkyd+TQL1tv+F76V5vTsIkNweYHumWOxLIt/FJ4fqZG4T5GMTQQivMqD\npaI0IVrO+Wm3cWQYvNdf/EcC3DYhYqHANkRsbUYwXaREnI/tU1PjnH2XUJ69ABWz\ntdc+8sXyMoMMM1U4FLiTWzGyh0rUKkW5JXzJR2OEQT0IG+0Tf2Glyk0El0/OJPg/\ncZQzaO1o+H8DiUzs/7Pz72yDqo0R7fQ+mOCCnQIDAQABAoIBAA6/c9dGmK2mae4z\nyQ5KrOFdvC1TNhej+sZx+CwyzEJUSvSuHcvQCXFBAz8FY92hhvPKcX66jINXZ+4/\nCmWAQ5YyhcRiow0Y91HvsS0bywoknX3q6kxBFodmyyCWFkgd5iMTADb1Lx0a27Y7\njlS4Dl5gyiGmxUN2Ng24wWEAjE8ZNuI0lrtr5IZKp+s5IAi/rb5AG/mL7EzicE8c\nmGP+QAa+nzwhAwNhFwVID230xen/ZcoL1d77hxeARNqJUxoR25gwJd6Ebg2y9pDW\nVu6cbbzgdGUCfQYlMEoAamAkCswOsDpVDBXwQnt2A537n6Wq2bgYIKusHr9thtxP\n/5ubQLUCgYEA4zYuBG2vtLHnvce26P8o2j1xcJS9K0ozkah9JFl3hqFN0sAqLlz7\n/Fm1jA4kzHJS3d0UqP3AMDxY3HkIqCn4Be7lqeAAe2AfqkOZpt9MDNv4VwKe9sPb\nViW1qjL3FxziLC/YWTRNSlpwRjqJJGhA+UQt8rOia1k/zXmrEs7bXLcCgYEAwPsu\nK3j5QoAiziYVMYf5iCzWwAM9Ljpf9gw23lefTdIzhhfFtJplVRSyxRGU0UZ84GMI\nTd5zmcIF/1KUfhqmeiQzz6NIPEYEReahjpQ/sOH/Gk5Rwr3QwYPrwAu5x+kk/SRi\nKPkqw7APTR0sMQBcUq+ZYwGYLGPMdd1zUdLfb0sCgYBkuz11iydtxb3G/obSD2WO\nM9VaIycmzRPFzNwGRH/gOR0mhTluKp0wyJjbSd34oeqpH/2r2ivddrOysxoqa8jg\n4IQDZyLvj7MaKjQxrieqP89+y9Or9TMFo1xB46x2G8EN8/xHuA9YGnZSPFtWv72m\nhRqV0hv82amWsA0vHnRUSwKBgDsKHXvrTMbNkNhkykMXCH5iyWiBFSyZa1ZJMlgf\nknsqfdzeVPwF6E55QKAN2uuTlwzG/3ljPxahR1hvmUJjQN9JSBiUKbtW6GPCRVbr\nf/jLi1Iu99COZdluVKeybqn8Z/aSNP24DR9FM8kxzZ1IMPaTBmhFypp6BclhcLBt\nxTG1AoGAfcrkVbV1SOy7fECUtMpUECcw0yU4GWj3sR2RbII63C500RVYQlUpUaRR\naANbASHTVR4myOKtGSxEUhAQHlxFDwsDL7W3gzAqTFbEDp1xAAUyT/nkOAhQjEm4\nORFdDETeXLQG1KMUj+8AdnhfYp3JTdft6rmPpZEBUFiCAUMAvb0=\n-----END RSA PRIVATE KEY-----\n",
    "user_id": "f79791beca3c48159ac2553fff22e166",
    "name": "demo1",
    "fingerprint": "57:a7:a2:ed:5f:aa:e7:54:62:2e:bb:e7:92:22:cb:40"
  }
}

2. Import the key.

(1) Interface related information

Uri format: post / v2.1 / {project_ id}/os-keypairs

(2) Request example

POST: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/os-keypairs

Body:

{
    "keypair": {
        "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDY8wMTdBYiJgi62o6eShoOlSKx3CZ3cE6PHisDblfK3Y0Bg7EHV7iV9c74pqsrIhK0xuGUuO1NxDQWbkwLTPN4F9Iy5CIYohLuMIpbln6LDtfRPpdhEh3lxL8MM61gyfpKzeKkwkEpSFj27Rgh6zCyJgBpkA2A0HTP737UlitahL4faCWDIS+Vj6mbcfkWiMhuMCzTZgSKAZ4PfoG4B5HJhR52C6A4XLiQFT9heh9gnIsIG+uTogTKUbcJKuN7M6AraJpul6eHhV9YI4433sDmuiBF/njvreVPWwAHlAkgT9I8q1T/cfEFiwzXpdGbkK5O8NC7K+qNbbdKihlahONt Generated-by-Nova\n",
        "type": "ssh",
        "name": "demo2",
        "user_id": "fake"
    }
}

(3) Response examples

{
  "keypair": {
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDY8wMTdBYiJgi62o6eShoOlSKx3CZ3cE6PHisDblfK3Y0Bg7EHV7iV9c74pqsrIhK0xuGUuO1NxDQWbkwLTPN4F9Iy5CIYohLuMIpbln6LDtfRPpdhEh3lxL8MM61gyfpKzeKkwkEpSFj27Rgh6zCyJgBpkA2A0HTP737UlitahL4faCWDIS+Vj6mbcfkWiMhuMCzTZgSKAZ4PfoG4B5HJhR52C6A4XLiQFT9heh9gnIsIG+uTogTKUbcJKuN7M6AraJpul6eHhV9YI4433sDmuiBF/njvreVPWwAHlAkgT9I8q1T/cfEFiwzXpdGbkK5O8NC7K+qNbbdKihlahONt Generated-by-Nova\n",
    "user_id": "f79791beca3c48159ac2553fff22e166",
    "name": "demo2",
    "fingerprint": "dd:44:45:49:d9:f6:4f:c0:24:2d:81:aa:c4:4b:83:c2"
  }
}

2. Record the name information in the body of the response message. For example, “demo2” in this case.

Step 6: create a cloud server with key pair login and authentication.

(1) Interface related information

Uri format: post / v2.1 / {project_ id}/servers

explain:

This example specifies the image to create a cloud server, so:

● block_ device_ mapping_ In v2.1, “source”_ Type “should be set to” image “,” UUID “to the selected image ID,” destination “_ Type “is set to” volume “,” boot “_ Index “is set to” 0 “.

● “volume_ Size “should be greater than or equal to the minimum value specified in the mirror metadata.

(2) Request example

POST: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/servers

Body:

{
    "server": {
        "flavorRef": "c1.large",
        "name": "zttestvm1",
        "block_device_mapping_v2.1": [{
            "source_type": "image",
            "destination_type": "volume",
            "volume_type": "SATA",
            "volume_size": "40",
            "delete_on_termination": "true",
            "uuid": "11e8f727-d439-4ed1-b3b8-33f46c0379c4",
            "boot_index": "0"
        }],
        "networks": [{
            "uuid": "fb68519f-a7c0-476e-98d4-2e4cf6de6def"
        }],
        "key_name": "demo2",
        "availability_zone": "az_test_01"
    }
}

(3) Response examples

{
  "server": {
    "security_groups": [
      {
        "name": "default"
      }
    ],
    "OS-DCF:diskConfig": "MANUAL",
    "links": [
      {
        "rel": "self",
        "href": "https://None/v2.1/74610f3a5ad941998e91f076297ecf27/servers/6d311127-bce1-48db-bf0f-cac9f8f7f077"
      },
      {
        "rel": "bookmark",
        "href": "https://None/74610f3a5ad941998e91f076297ecf27/servers/6d311127-bce1-48db-bf0f-cac9f8f7f077"
      }
    ],
    "id": "6d311127-bce1-48db-bf0f-cac9f8f7f077",
    "adminPass": "WcC4QoVZPXpV"
  }
}

Step 7: set password login method.

(1) When using non cloud init image to create cloud server, both windows and Linux systems use “adminpass” parameter to implement password injection.

(2) When cloud init image is used to create a cloud server:

L for Linux system, only “user” can be used_ Data “for password injection,” user “_ Data “string length is less than 65535 and must be Base64 encrypted;

L for Windows system, you can only use the metadata “admin”_ Pass “.

Step 8: create an elastic cloud server with password login and authentication.

explain:

This example specifies image to create elastic cloud server, so:

(1)block_ device_ mapping_ In v2.1, “source”_ Type “should be set to” image “,” UUID “to the selected image ID,” destination “_ Type “is set to” volume “,” boot “_ Index “is set to” 0 “.

(2)“volume_ Size “should be greater than or equal to the minimum value specified in the mirror metadata.

1. Create an elastic cloud server with non cloud init image and password login authentication.

(1) Interface related information

Uri format: post / v2.1 / {project_ id}/servers

(2) Request example

POST: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/servers

Body:

{
    "server": {
        "flavorRef": "c1.large",
        "name": "zttestvm1",
        "adminPass":"[email protected]",
        "block_device_mapping_v2.1": [{
            "source_type": "image",
            "destination_type": "volume",
            "volume_type": "SATA",
            "volume_size": "40",
            "delete_on_termination": "true",
            "uuid": "11e8f727-d439-4ed1-b3b8-33f46c0379c4",
            "boot_index": "0"
        }],
        "networks": [{
            "uuid": "fb68519f-a7c0-476e-98d4-2e4cf6de6def"
        }],
        "availability_zone": "az_test_01"
    }
}

(3) Response examples

{
  "server": {
    "security_groups": [
      {
        "name": "default"
      }
    ],
    "OS-DCF:diskConfig": "MANUAL",
    "links": [
      {
        "rel": "self",
        "href": "https://None/v2.1/74610f3a5ad941998e91f076297ecf27/servers/73991cff-37c6-491a-9a8a-377397729fce"
      },
      {
        "rel": "bookmark",
        "href": "https://None/74610f3a5ad941998e91f076297ecf27/servers/73991cff-37c6-491a-9a8a-377397729fce"
      }
    ],
    "id": "73991cff-37c6-491a-9a8a-377397729fce",
    "adminPass": "[email protected]"
  }
}

2. Create a cloud init image (taking Linux as an example) and log in to the elastic cloud server for authentication by password.

(1) Interface related information

Uri format: post / v2.1 / {project_ id}/servers

(2) Request example

POST: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/servers

Body:

{
    "server": {
        "flavorRef": "c1.large",
        "name": "zttestvm2", 
"user_data":"IyEvYmluL2Jhc2gKZWNobyAncm9vdDokNiRuaERlcUIkajBkelVMbkFrbWo4bWlFREFzT0VONkVPdGg1RmdqWnQybUVWZVRocC5OVDJXelZVdzFuNzhnL3dNdDE0dVpSQ1V3LzhHS3VGdEViQ0lPQS5vN1BZQzEnIHwgY2hwYXNzd2QgLWU7",
        "block_device_mapping_v2.1": [{
            "source_type": "image",
            "destination_type": "volume",
            "volume_type": "SATA",
            "volume_size": "40",
            "delete_on_termination": "true",
            "uuid": "11e8f727-d439-4ed1-b3b8-33f46c0379c4",
            "boot_index": "0"
        }],
        "networks": [{
            "uuid": "fb68519f-a7c0-476e-98d4-2e4cf6de6def"
        }],
        "availability_zone": "az_test_01"
    }
}

(3) Response examples

{
  "server": {
    "security_groups": [
      {
        "name": "default"
      }
    ],
    "OS-DCF:diskConfig": "MANUAL",
    "links": [
      {
        "rel": "self",
        "href": "https://None/v2.1/74610f3a5ad941998e91f076297ecf27/servers/7c11f362-cc96-4306-85b6-b432a639ca5e"
      },
      {
        "rel": "bookmark",
        "href": "https://None/74610f3a5ad941998e91f076297ecf27/servers/7c11f362-cc96-4306-85b6-b432a639ca5e"
      }
    ],
    "id": "7c11f362-cc96-4306-85b6-b432a639ca5e",
    "admin_pass": "J3xMSivHCuq5"
  }
}

Step 9: confirm that the ECS is created successfully.

(1) Interface related information

Uri format: get / v2.1 / {project_ id}/servers/{server_ Id}

(2) Request example

GET: https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/servers/0c71c0da-8852-4c56-a1d1-3a9b9bcb6da6

Among them:

0c71c0da-8852-4c56-a1d1-3a9b9bcb6da6 is the UUID of the created ECs.

(3) Response examples

{
  "server": {
    "tenant_id": "74610f3a5ad941998e91f076297ecf27",
    "addresses": {
      "2a6f4aa6-d93e-45f5-a8cb-b030dbf8cd68": [
        {
          "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:88:01:1b",
          "OS-EXT-IPS:type": "fixed",
          "addr": "192.168.2.192",
          "version": 4
        }
      ]
    },
    "metadata": {},
    "OS-EXT-STS:task_state": null,
    "OS-DCF:diskConfig": "MANUAL",
    "OS-EXT-AZ:availability_zone":  "az_test_01",
    "links": [
      {
        "rel": "self",
        "href": "https://None/v2.1/74610f3a5ad941998e91f076297ecf27/servers/0c71c0da-8852-4c56-a1d1-3a9b9bcb6da6"
      },
      {
        "rel": "bookmark",
        "href": "https://None/74610f3a5ad941998e91f076297ecf27/servers/0c71c0da-8852-4c56-a1d1-3a9b9bcb6da6"
      }
    ],
    "OS-EXT-STS:power_state": 1,
    "id": "0c71c0da-8852-4c56-a1d1-3a9b9bcb6da6",
    "os-extended-volumes:volumes_attached": [
      {
        "id": "b551445a-e749-4d53-932a-638a455cb6c3"
      }
    ],
    "OS-EXT-SRV-ATTR:host": "pod1_test_01",
    "image": {
      "links": [
        {
          "rel": "bookmark",
          "href": "https://None/74610f3a5ad941998e91f076297ecf27/images/11e8f727-d439-4ed1-b3b8-33f46c0379c4"
        }
      ],
      "id": "11e8f727-d439-4ed1-b3b8-33f46c0379c4"
    },
    "OS-SRV-USG:terminated_at": null,
    "accessIPv4": "",
    "accessIPv6": "",
    "created": "2018-05-25T01:47:11Z",
    "hostId": "b2792bef989888d2df1f51bff81de5ac58a4117f4e9ec3059c1a0410",
    "OS-EXT-SRV-ATTR:hypervisor_hostname": "[email protected]",
    "key_name": null,
    "flavor": {
      "links": [
        {
          "rel": "bookmark",
          "href": "https://None/74610f3a5ad941998e91f076297ecf27/flavors/c1.large"
        }
      ],
      "id": "c1.large"
    },
    "security_groups": [
      {
        "name": "default"
      }
    ],
    "config_drive": "",
    "OS-EXT-STS:vm_state": "active",
    "OS-EXT-SRV-ATTR:instance_name": "instance-001883cd",
    "user_id": "f79791beca3c48159ac2553fff22e166",
    "name": "zttestvm1",
    "progress": 0,
    "OS-SRV-USG:launched_at": "2018-05-25T01:47:55.755922",
    "updated": "2018-05-25T01:47:55Z",
    "status": "ACTIVE"
  }
}

According to the instructions, I quickly completed the construction of the cloud server. I can’t help being surprised. How can this kid understand so much? Wait… Huawei cloud API Explorer? openOfficial website of Huawei cloud API ExplorerIt seems that I have opened the door to a new world. There are many configured environments and interfaces. You can call debugging directly. I’m afraid nothing will hinder me in the future!

At present, API Explorer platform has opened 70 + cloud services such as EI enterprise intelligence, computing, application services, network, software development platform, video, etc., with 2000 + APIs and 6000 + error codes online. During the preliminary trial operation, the API interface on Huawei cloud API Explorer platform has been successfully accessed by many enterprises.

Click to view details:Huawei cloud one stop API solution platform API Explorer Online

It is reported that Huawei cloud API Explorer platform will realize more functions in the next few months, such as supporting SDK sample code, CLI and other features, and will open more cloud service API interfaces to connect more developers to realize innovation and broaden innovation boundaries.

Click follow to learn about Huawei’s new cloud technologies~

Recommended Today

Summary of recent use of gin

Recently, a new project is developed by using gin. Some problems are encountered in the process. To sum up, as a note, I hope it can help you. Cross domain problems Middleware: func Cors() gin.HandlerFunc { return func(c *gin.Context) { //Here you can use * or the domain name you specify c.Header(“Access-Control-Allow-Origin”, “*”) //Allow header […]