我找不到在 AWS lambda 中使用 ktor 应用程序的方法...
也就是说,我只需要“执行”管道,而不是像http://ktor.io/servers/engine.html 中描述的那样启动嵌入式服务器或使用外部服务器。
我想这或多或少像 TestEngine,但我对 ktor 框架不太熟悉。
笔记 :
我已经找到了为每个 lambda 运行一个 kotlin 函数的示例(恕我直言,最好的教程是https://aws.amazon.com/fr/blogs/machine-learning/use-amazon-rekognition-to-build-an-end- to-end-serverless-photo-recognition-system/)。
问题是我不想为每个函数管理一个 lambda(我想要每个 lambda 一个微服务,该微服务负责多个紧密耦合的操作)
这与How do I set or remove the Default Response Content Type Using SwashBuckle基本相同,但对于 .NET Core 3.0
默认情况下,在 .NET Core 3.0 中,你配置了一个 web api,services.AddControllers()然后你配置了 swagger with swashbuckle with services.AddSwaggerGen()+app.UseSwagger()
这工作正常,但是 swagger.json 包含每个操作的多种响应内容类型(text/plain + application/json + text/json)
我知道我可以通过添加[Produces]和[Consumes]到我的操作来限制这些响应内容类型,但我想为每个操作避免这种情况(即我想在全局范围内这样做)
请注意,我最好使用 System.Text.Json,但如果您有一个仅适用于 Newtonsoft.JSON 的解决方案,那么它总比没有好;)
目前,我启用 Serilog 来记录向我的服务器发出的所有 HTTP 请求(请参阅下面的 Program.cs 和logging.json)。
但是,Openshift 正在调用 /ready 和 /live,我不想记录这些请求
{"@t":"2020-12-17T15:02:08.7321442Z","@m":"HTTP \"GET\" \"/ready\" responded 200 in 41.3777 ms","@i":"62d0885c","RequestMethod":"GET","RequestPath":"/ready","StatusCode":200,"Elapsed":41.3777,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HM52JISL6NBA:00000001","SpanId":"|d7e25f1-47c5ac680b1d5fd1.","TraceId":"d7e25f1-47c5ac680b1d5fd1","ParentId":"","ConnectionId":"0HM52JISL6NBA"}
Run Code Online (Sandbox Code Playgroud)
问题是我仍然想记录其他请求......
有人可以向我解释一下我可以在哪里挂钩这个逻辑吗?
程序.cs
class Program
{
static async Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(provider: ConfigMapFileProvider.FromRelativePath("conf"), path: "logging.json", optional: false, reloadOnChange: true)
.Build()
)
.Enrich.FromLogContext()
.WriteTo.Console(new RenderedCompactJsonFormatter())
.CreateLogger();
await Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddJsonFile("conf/network.json", optional: false, reloadOnChange: false);
config.AddJsonFile("conf/messagebus.json", optional: false, reloadOnChange: false);
config.AddJsonFile("conf/auth.json", optional: false, reloadOnChange: false);
config.AddJsonFile("conf/appsettings.json", optional: false, reloadOnChange: false);
}) …Run Code Online (Sandbox Code Playgroud) 我发现很多关于在heroku下强制执行HTTPS的问题,但没有关于java的回复.
这是我找到的链接:
Scala:http://www.andersen-gott.com/2012/03/using-unfiltered-and-https-on-heroku.html
Rails:Rails - 如何从http://example.com重定向到https://www.example.com
请注意我使用Spring MVC 3.1所以我更喜欢基于WebMvcConfigurerAdapter.addInterceptors(InterceptorRegistry注册表)的解决方案
这是我的AC#项目中的代码,该代码针对Visual Studio 2019(16.3.9)的.NET Core 3.0(因此我应该在C#8.0中)
public interface IJsonAble
{
public string ToJson() => System.Text.Json.JsonSerializer.Serialize(this);
}
public class SumRequest : IJsonAble
{
public int X { get; set; }
public int Y { get; set; }
public void Tmp()
{
new SumRequest().ToJson(); //compile error
}
}
Run Code Online (Sandbox Code Playgroud)
编译错误是:
CS1061'SumRequest'不包含'ToJson'的定义,并且找不到可以接受的扩展方法'ToJson'接受类型为'SumRequest'的第一个参数(您是否缺少using指令或程序集引用?)
有人可以阐明这种行为吗?
https://medium.com/google-developers/understanding-migrations-with-room-f01e04b07929 上有一篇关于房间迁移的精彩文章
但是,我仍然想念 Room 中的“灾难”恢复机制(即 fallbackToDestructiveRecreationOnMigrationError() 会在发生奇怪的事情时清除并重新创建数据库)
这是发生在我们身上的事情:
开发人员通过迁移推送了版本 9,但架构 9.json 不符合(我不知道这怎么可能)=> 房间进行了迁移并且没有错误。
然后,当我们提供版本 10 时,文件 9.json 已更改 => 房间崩溃,用户无法再访问该应用程序(这很正常)。
我们不得不告诉我们的用户擦除他们的数据(这不是技术问题,因为我们在应用程序启动时重新同步数据库,但这是一个公共关系问题)
我认为在构建器中使用 openHelperFactory 应该是可能的,但这对我来说还远未深入到房间内部:(
编辑后,我按照惯例在列表上重定向。
但是,我需要在列表 URL 中提供其他参数。
有没有办法在 SimpleForm/Edit 上“欺骗”以自定义重定向?
这是我的代码的相关部分:
const ProviderUserEditActions = ({ basePath, data }) => {
if (! data) return null
return (
<CardActions style={cardActionStyle}>
<ListButton basePath={basePath+'?'+queryString.stringify({providerId:data.providerId, providerName:data.providerName})} />
<RefreshButton />
</CardActions>
);
}
export const ProviderUserEdit = (props) => (
<Edit actions={<ProviderUserEditActions/>} title={<ProviderUserEditTitle />} {...props}>
{/*redirect=false will cause the loosing of the URL parameters :(
but this is the "least worst", because otherwise it would redirect to
'list' but without URL parameters it will completely crash...
we hope …Run Code Online (Sandbox Code Playgroud) c# ×2
android ×1
android-room ×1
asp.net-core ×1
aws-lambda ×1
c#-8.0 ×1
heroku ×1
https ×1
java ×1
ktor ×1
react-admin ×1
serilog ×1
swashbuckle ×1