小编Lop*_*uch的帖子

ASP.NET Core 3 - 在 services.AddSingelton<IMySingletone, MySingletone>(); 之后立即实例化单例

如何立即实例化单例

services.AddSingelton<IMySingleton, MySingleton>()
Run Code Online (Sandbox Code Playgroud)

我现在正在使用这个肮脏的解决方法(GetService在每个请求中调用):

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    app.ApplicationServices.GetService<IFirebaseApp_ForInjection>();

    //......
}
Run Code Online (Sandbox Code Playgroud)

我知道我的单例应该在构造函数注入需要时实例化,但我不需要将它注入到任何构造函数中。

c# singleton dependency-injection asp.net-core-3.0

4
推荐指数
1
解决办法
1640
查看次数

Angular 8 - HttpInterceptor - 读取响应头

我在 HttpInterceptor 的响应中缺少 http 标头。我可以得到一个正文,但不能得到标题。请参阅附加的输出和我的代码。

@Injectable()
export class ApiVersionInterceptor implements HttpInterceptor {
    intercept(
        req: import("@angular/common/http").HttpRequest<any>,
        next: import("@angular/common/http").HttpHandler
    ): import("rxjs").Observable<import("@angular/common/http").HttpEvent<any>> {
        return next.handle(req).pipe(
            tap(httpEvent=>{
                // Skip request
                if(httpEvent.type === 0){
                    return;
                }
                console.log("response: ", httpEvent);
            })

        );
    }
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

response http-headers angular-http-interceptors angular

3
推荐指数
1
解决办法
3505
查看次数