0
Help us understand the problem. What are the problem?

posted at

updated at

Google Cloud Functions: 加算

index.js
/**
 * Responds to any HTTP request.
 *
 * @param {!express:Request} req HTTP request context.
 * @param {!express:Response} res HTTP response context.
 */
exports.sum_up = (req, res) => {
  var str_out = ""
  str_out += "これはテストです。\n"
  str_out += "Good Evening\n"
  str_out += "今晩は\n"
  str_out += "Apr/04/2022 PM 18:02\n"
  const aa = req.body['aa']
  const bb = req.body['bb']
  const sum = parseInt(aa) + parseInt(bb)
  str_out += "aa = " + aa + "\n"
  str_out += "bb = " + bb + "\n"
  str_out += "sum = " + sum + "\n"
  res.send(str_out)
};

curl のテストスクリプト

curl_post.sh
HOST="https://asia-northeast1-my-project-aug-29-2016.cloudfunctions.net"
#
curl $HOST"/test-function-uchida-apr04" \
	-H "Authorization: bearer $(gcloud auth print-identity-token)" \
	-d 'aa=12&bb=45'
echo ""

Httpie のテストスクリプト

httpie_post.sh
HOST="https://asia-northeast1-my-project-aug-29-2016.cloudfunctions.net"
#
http $HOST"/test-function-uchida-apr04" \
	"Authorization: bearer $(gcloud auth print-identity-token)" \
	aa=19 bb=35

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
0
Help us understand the problem. What are the problem?