How can I hook into RegisterResponseContentEncodingForContentType #1255
-
How can I hook into AbstractAspNetCoreFunction.RegisterResponseContentEncodingForContentType to add additional content types that I need Base64 encoded using the For better or worse, I want to add |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I've found a work around, but seems a bit hacky. Ideally there is a more elegant way... I basically had to copy small parts of the source and modify them, creating my own custom All that to add the one line for Custom LambdaRuntimeSupportServerpublic class CustomAPIGatewayHttpApiV2LambdaRuntimeSupportServer : LambdaRuntimeSupportServer
{
public CustomAPIGatewayHttpApiV2LambdaRuntimeSupportServer(IServiceProvider serviceProvider)
: base(serviceProvider)
{
}
protected override HandlerWrapper CreateHandlerWrapper(IServiceProvider serviceProvider)
{
var handler = new APIGatewayHttpApiV2MinimalApi(serviceProvider).FunctionHandlerAsync;
return HandlerWrapper.GetHandlerWrapper(handler, new DefaultLambdaJsonSerializer());
}
public class APIGatewayHttpApiV2MinimalApi : APIGatewayHttpApiV2ProxyFunction
{
public APIGatewayHttpApiV2MinimalApi(IServiceProvider serviceProvider)
: base(serviceProvider)
{
// THIS IS THE LINE I WANT/NEED TO ADD
RegisterResponseContentEncodingForContentType("font/woff2", ResponseContentEncoding.Base64);
}
}
} Custom ExtensionMethodpublic static class ServiceCollectionExtensions
{
public static IServiceCollection AddAWSLambdaHostingCustomized(this IServiceCollection services)
{
// Not running in Lambda so exit and let Kestrel be the web server
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AWS_LAMBDA_FUNCTION_NAME")))
return services;
Utilities.EnsureLambdaServerRegistered(services, typeof(CustomAPIGatewayHttpApiV2LambdaRuntimeSupportServer));
return services;
}
} |
Beta Was this translation helpful? Give feedback.
I've found a work around, but seems a bit hacky. Ideally there is a more elegant way...
I basically had to copy small parts of the source and modify them, creating my own custom
APIGatewayHttpApiV2LambdaRuntimeSupportServer
and then a custom extension method to register it similar toAddAWSLambdaHosting
All that to add the one line for
RegisterResponseContentEncodingForContentType
Custom LambdaRuntimeSupportServer