Skip to content

Commit e23e2ff

Browse files
Move Endpoint url to a constant.
1 parent 2007b9c commit e23e2ff

File tree

8 files changed

+20
-13
lines changed

8 files changed

+20
-13
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace HyperCache.Web.Constants;
2+
3+
public class ApiConstant
4+
{
5+
public const string BaseUrl = "https://localhost:7148";
6+
public const string CustomProperties = "api/customproperties";
7+
public const string CustomPropertiesPaged = "api/customproperties/paged";
8+
public const string CustomPropertiesSearch = "api/customproperties/search";
9+
public const string CustomPropertiesAll = "api/customproperties/all";
10+
}

HyperCache.Web/HyperCache.Web.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@
1111
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" PrivateAssets="all" />
1212
</ItemGroup>
1313

14-
<ItemGroup>
15-
<ProjectReference Include="..\HyperCache.Shared\HyperCache.Shared.csproj" />
16-
</ItemGroup>
17-
1814
</Project>

HyperCache.Web/Layout/NavMenu.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="top-row ps-3 navbar navbar-dark">
22
<div class="container-fluid">
3-
<a class="navbar-brand" href="">HyperCache.Web</a>
3+
<a class="navbar-brand" href="">HyperCache</a>
44
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
55
<span class="navbar-toggler-icon"></span>
66
</button>

HyperCache.Web/Pages/PropertyDetails.razor

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
@page "/property-details/{id}"
2-
@using HyperCache.Shared.Dtos
3-
@inject HttpClient Http
42

53
<div class="container mt-4">
64
<h3 class="text-primary">Property Details</h3>
@@ -35,7 +33,7 @@
3533
{
3634
if (!string.IsNullOrEmpty(Id))
3735
{
38-
property = await Http.GetFromJsonAsync<CustomPropertyDto>($"CustomProperties/{Id}");
36+
property = await Http.GetFromJsonAsync<CustomPropertyDto>($"{ApiConstant.CustomProperties}/{Id}");
3937
}
4038
}
4139
}

HyperCache.Web/Pages/Search.razor

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
@page "/search"
2-
@using HyperCache.Shared.Dtos
3-
@inject HttpClient Http
42

53
<div class="container mt-4">
64
<h3 class="text-primary">Search Custom Properties</h3>
@@ -44,7 +42,7 @@
4442
{
4543
if (!string.IsNullOrWhiteSpace(searchKeyword))
4644
{
47-
properties = await Http.GetFromJsonAsync<List<CustomPropertyDto>>($"CustomProperties/search?keyword={searchKeyword}");
45+
properties = await Http.GetFromJsonAsync<List<CustomPropertyDto>>($"{ApiConstant.CustomPropertiesSearch}?keyword={searchKeyword}");
4846
}
4947
}
5048
}

HyperCache.Web/Program.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
using HyperCache.Web;
2+
using HyperCache.Web.Constants;
23
using Microsoft.AspNetCore.Components.Web;
34
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
45

56
var builder = WebAssemblyHostBuilder.CreateDefault(args);
67
builder.RootComponents.Add<App>("#app");
78
builder.RootComponents.Add<HeadOutlet>("head::after");
89

9-
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7148/api/") });
10+
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(ApiConstant.BaseUrl) });
1011

1112
await builder.Build().RunAsync();

HyperCache.Web/_Imports.razor

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@
88
@using Microsoft.JSInterop
99
@using HyperCache.Web
1010
@using HyperCache.Web.Layout
11+
12+
@inject HttpClient Http
13+
@using HyperCache.Web.Constants
14+
@using HyperCache.Web.Dtos

HyperCache.Web/wwwroot/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<meta charset="utf-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>HyperCache.Web</title>
7+
<title>HyperCache</title>
88
<base href="/" />
99
<link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.min.css" />
1010
<link rel="stylesheet" href="css/app.css" />

0 commit comments

Comments
 (0)