-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webUI/ service configruations updated with extension method
- Loading branch information
1 parent
4452ddb
commit 77c5871
Showing
2 changed files
with
134 additions
and
108 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
MultiShop/Frontends/MultiShop.WebUI/Extensions/ServiceExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
using MultiShop.WebUI.Handlers; | ||
using MultiShop.WebUI.Services.Abstract; | ||
using MultiShop.WebUI.Services.BasketServices; | ||
using MultiShop.WebUI.Services.CatalogServices.AboutServices; | ||
using MultiShop.WebUI.Services.CatalogServices.BrandServices; | ||
using MultiShop.WebUI.Services.CatalogServices.CategoryServices; | ||
using MultiShop.WebUI.Services.CatalogServices.CategorySlideServices; | ||
using MultiShop.WebUI.Services.CatalogServices.ContactServices; | ||
using MultiShop.WebUI.Services.CatalogServices.ProductDetailServices; | ||
using MultiShop.WebUI.Services.CatalogServices.ProductImageServices; | ||
using MultiShop.WebUI.Services.CatalogServices.ProductServices; | ||
using MultiShop.WebUI.Services.CommentServices; | ||
using MultiShop.WebUI.Services.Concrete; | ||
using MultiShop.WebUI.Services.DiscountServices; | ||
using MultiShop.WebUI.Services.MessageServices; | ||
using MultiShop.WebUI.Services.OrderServices.OrderAddressServices; | ||
using MultiShop.WebUI.Services.OrderServices.OrderingServices; | ||
using MultiShop.WebUI.Settings; | ||
|
||
namespace MultiShop.WebUI.Extensions | ||
{ | ||
public static class ServiceExtensions | ||
{ | ||
public static void AddCustomHttpClients(this IServiceCollection services, ServiceApiSettings values) | ||
{ | ||
//CategoryService Configuration | ||
services.AddHttpClient<ICategoryService, CategoryService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Catalog.Path}"); | ||
}).AddHttpMessageHandler<ClientCredentialTokenHandler>(); | ||
|
||
|
||
//ProductService Configuration | ||
services.AddHttpClient<IProductService, ProductService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Catalog.Path}"); | ||
}).AddHttpMessageHandler<ClientCredentialTokenHandler>(); | ||
|
||
|
||
//CategorySlideService Configuration | ||
services.AddHttpClient<ICategorySlideService, CategorySlideService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Catalog.Path}"); | ||
}).AddHttpMessageHandler<ClientCredentialTokenHandler>(); | ||
|
||
|
||
// BrandService Configuration | ||
services.AddHttpClient<IBrandService, BrandService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Catalog.Path}"); | ||
}).AddHttpMessageHandler<ClientCredentialTokenHandler>(); | ||
|
||
|
||
// AboutService Configuration | ||
services.AddHttpClient<IAboutService, AboutService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Catalog.Path}"); | ||
}).AddHttpMessageHandler<ClientCredentialTokenHandler>(); | ||
|
||
|
||
// ProductImageService Configuration | ||
services.AddHttpClient<IProductImageService, ProductImageService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Catalog.Path}"); | ||
}).AddHttpMessageHandler<ClientCredentialTokenHandler>(); | ||
|
||
|
||
// ProductDetailService Configuration | ||
services.AddHttpClient<IProductDetailService, ProductDetailService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Catalog.Path}"); | ||
}).AddHttpMessageHandler<ClientCredentialTokenHandler>(); | ||
|
||
|
||
// ContactService Configuration | ||
services.AddHttpClient<IContactService, ContactService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Catalog.Path}"); | ||
}).AddHttpMessageHandler<ClientCredentialTokenHandler>(); | ||
|
||
|
||
// CommentService Configuration | ||
services.AddHttpClient<ICommentService, CommentService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Comment.Path}"); | ||
}).AddHttpMessageHandler<ClientCredentialTokenHandler>(); | ||
|
||
|
||
// BasketService Configuration | ||
services.AddHttpClient<IBasketService, BasketService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Basket.Path}"); | ||
}).AddHttpMessageHandler<ResourceOwnerPasswordTokenHandler>(); | ||
|
||
|
||
// DiscountService Configuration | ||
services.AddHttpClient<IDiscountService, DiscountService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Discount.Path}"); | ||
}).AddHttpMessageHandler<ResourceOwnerPasswordTokenHandler>(); | ||
|
||
|
||
// OrderAddressService Configuration | ||
services.AddHttpClient<IOrderAddressService, OrderAddressService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Order.Path}"); | ||
}).AddHttpMessageHandler<ResourceOwnerPasswordTokenHandler>(); | ||
|
||
|
||
// OrderingService Configuration | ||
services.AddHttpClient<IOrderingService, OrderingService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Order.Path}"); | ||
}).AddHttpMessageHandler<ResourceOwnerPasswordTokenHandler>(); | ||
|
||
|
||
// MessageService Configuration | ||
services.AddHttpClient<IMessageService, MessageService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri($"{values.OcelotUrl}/{values.Message.Path}"); | ||
}).AddHttpMessageHandler<ResourceOwnerPasswordTokenHandler>(); | ||
|
||
|
||
// IdentityServer Configuration | ||
services.AddHttpClient<IUserService, UserService>(opt => | ||
{ | ||
opt.BaseAddress = new Uri(values.IdentityServerUrl); | ||
}).AddHttpMessageHandler<ResourceOwnerPasswordTokenHandler>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters