尝试发布到我在API网关中创建的API:
{
"Message": "User: anonymous is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-west-2:***********:jrr7u1ekrr/v0/POST/user"
}
Run Code Online (Sandbox Code Playgroud)
如何更新CloudFormation中的策略以使POST端点公开可用?我在声明带有AWS::ApiGateway::RestApi资源类型的API 。
API政策属性为:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "execute-api:/*/POST/user"
}
]
}
Run Code Online (Sandbox Code Playgroud) 我想graphql-tools/addMockFunctionsToSchema按照以下模式在模拟解析器中模拟错误响应:
const mocks = {
...,
Mutation: () => ({
getToken: (_, { password }) => {
if (password === 'password') {
return { value: casual.uuid }
} else {
throw new Error('Incorrect email or password')
}
}
})
}
const schema = makeExecutableSchema({`
type Token { value: ID! }
type Mutation {
getToken(email: String!, password: String!): Token
}
`});
addMockFunctionsToSchema({ schema, mocks});
Run Code Online (Sandbox Code Playgroud)
这可以正常工作,并且确实返回GraphQL错误,但是:
使用 apollo-link-state 观察派生状态的最佳方法是什么?
作为一个人为的例子,缓存存储了一个 Todo 项目列表。另一个组件需要跟踪 Todo 项目的总数。
存储totalTodos在本地状态会不太理想,因为每个解析器函数 ( updateTodo, deleteTodo, addTodo) 都必须写入缓存并更新totalTodos
query {
totalTodos
todos { ...
Run Code Online (Sandbox Code Playgroud)
如果有办法公开可观察的计算值会很好吗?
我想通过Cognito用户池对iOS设备进行身份验证以使用AppSync / S3服务。该AWSMobileClient提供了一些很好的便利,但初始化需要你包有一个awsconfiguration.json文件-我们的应用程序将动态定义。有没有办法手动配置?
我也在使用 sam cli 构建和部署 AWS Lambdas:
sam build 命令遍历应用程序中的函数,查找包含依赖项的清单文件(例如 requirements.txt),并自动创建部署工件,您可以使用 sam package 和 sam deploy 命令将其部署到 Lambda。
很酷的是,我可以使用选项标志--use-container来构建在类似 AWS Lambda 的 Docker 容器中具有本地编译依赖项的函数。
AWS Lambda 层呢?
我有一个功能:
CreateImagesLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.7
Handler: lambda_function.create
CodeUri: ./functions/image_handler/
...
Layers:
- !Ref LayerPillow
Run Code Online (Sandbox Code Playgroud)
使用具有本机编译依赖项的层(因此必须安装在 linux 上):
LayerPillow:
Type: AWS::Serverless::LayerVersion
Properties:
...
ContentUri: ./functions/layer_pillow/
Run Code Online (Sandbox Code Playgroud)
我可以通过使用amazonlinux:latestdocker 映像安装依赖项并复制到我的存储库来解决这个问题,但是很好奇 SAM 是否支持此功能
如果能够将 AWS 上的日志记录与我们的服务器日志合并起来,那就太好了 - 奇怪的是,我并没有看到太多关于使用 CloudWatch 记录客户端错误的话题。
\nAPI数据字段仅支持ASCII编码——但我需要支持Unicode(表情符号、外来字符等)
我想将用户的文本输入编码为转义的 unicode 字符串:
let textContainingUnicode = """
Let's go in the .
And some new lines.
"""
let result = textContainingUnicode.unicodeScalars.map { $0.escaped(asASCII: true)}
.joined(separator: "")
.replacingOccurrences(
of: "\\\\u\\{(.+?(?=\\}))\\}", <- converting swift format \\u{****}
with: "\\\\U$1", <- into format python expects
options: .regularExpression)
Run Code Online (Sandbox Code Playgroud)
result这是"Let\'s go \U0001F3CA in the \U0001F30A.\n And some new lines."
在服务器上用 python 解码:
codecs.decode("Let\\'s go \\U0001F3CA in the \\U0001F30A.\\n And some new lines.\n", 'unicode_escape')
但这听起来很有趣——我真的需要在 swift 中做这么多字符串操作才能获得转义的 unicode 吗?这些格式是否没有跨语言标准化?
我正在使用 Play 的 WSClient 与第三方服务进行交互
request = ws.url(baseUrl)
.post(data)
.map{ response =>
response.json.validate[MyResponseClass]
Run Code Online (Sandbox Code Playgroud)
响应可能是 aMyResponseClass也可能是ErrorResponse类似{ "error": [ { "message": "Error message" } ] }
是否有解析类或错误的典型方法?
我应该做这样的事情吗?
response.json.validateOpt[MyResponseClass].getOrElse(response.json.validateOpt[ErrorClass])
Run Code Online (Sandbox Code Playgroud) 我正在使用 Play 2.6.x 并且测试助手status(result)具有以下方法:
def status(of: Accumulator[ByteString, Result])(implicit timeout: Timeout, mat: Materializer): Int = status(of.run())
当编译器找不到隐式值时,运行测试会抛出:
could not find implicit value for parameter mat: akka.stream.Materializer
什么是 Materializer——我假设它是 Akka-HTTP 的一部分
我怎样才能提供一个?
我的模板:
{{#each collections }}
<span class="Category__Title">{{ @key }}</span>
{{#each this }}
<a href="{{ this.path }}">{{ this.title }}</a>
{{/each}}
{{/each}}
Run Code Online (Sandbox Code Playgroud)
渲染(this.path未定义):
<span class="Category__Title">French</span>
<a href="">Braised vegetables</a>
<span class="Category__Title">Thai</span>
<a href="">Rice noodles</a>
Run Code Online (Sandbox Code Playgroud)
我正在使用metalsmith:
metalsmith
.use(collections())
.use(markdown())
.use(templates({
engine: 'handlebars',
directory: 'templates'
}))
.use(permalinks({
pattern: ':title'
}))
.destination('./public')
Run Code Online (Sandbox Code Playgroud)
在编译时,我将日志记录到集合中
var m = metalsmith.metadata();
console.log(m.collections);
Run Code Online (Sandbox Code Playgroud)
我可以看到每个集合都有一个文件数组,每个文件都包含密钥'path'.控制台日志 - >
{ title: 'Braised vegetables',
date: '10/12/1923',
tags: [ 'braise', 'old world' ],
collection: [ 'french' ],
template: 'recipe.hbt',
contents: <Buffer 3...>,
mode: '0644',
stats: { }, …Run Code Online (Sandbox Code Playgroud) scala ×2
akka-http ×1
aws-amplify ×1
aws-lambda ×1
aws-sam-cli ×1
ios ×1
javascript ×1
metalsmith ×1
play-json ×1
sentry ×1
swift ×1
unicode ×1
ws-client ×1