Skip to content

Instantly share code, notes, and snippets.

@taikulawo
Created March 12, 2020 06:04
Show Gist options
  • Save taikulawo/183ca8aca78d8ea540d44cf21f0af407 to your computer and use it in GitHub Desktop.
Save taikulawo/183ca8aca78d8ea540d44cf21f0af407 to your computer and use it in GitHub Desktop.
阿里云函数计算-API网关-参数透传-函数计算-模板
# -*- coding: utf-8 -*-
import logging
import json
# if you open the initializer feature, please implement the initializer function, as below:
# def initializer(context):
# logger = logging.getLogger()
# logger.info('initializing')
def handler(event, context):
logger = logging.getLogger()
logger.info(event)
logger.info(context)
return {
"isBase64Encoded":False,
"statusCode":200,
"headers":{},
"body":"..."
}
# event结构
# {
# "path":"api request path",
# "httpMethod":"request method name",
# "headers":{all headers,including system headers},
# "queryParameters":{query parameters},
# "pathParameters":{path parameters},
# "body":"string of request payload",
# "isBase64Encoded":"true|false, indicate if the body is Base64-encode"
# }
# context存放ali相关的信息
# https://help.aliyun.com/document_detail/74756.html?spm=a2c4g.11174283.6.565.5b565212jrvRvY#general-handler-interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment