Fix API communication issues
This commit is contained in:
parent
25c320bf6b
commit
0923b55430
2 changed files with 14 additions and 10 deletions
|
@ -9,14 +9,14 @@ namespace Website.Data
|
|||
public BlogApi(HttpClient client) : base(client) {
|
||||
}
|
||||
|
||||
public async Task<BlogPost> GetPostByUrlAsync(string url) => await Get<BlogPost>("/get/" + url);
|
||||
public async Task<IEnumerable<BlogPost>> GetLatestPostsAsync(int count = 0, int offset = 0) => await Get<IEnumerable<BlogPost>>("/getlatestposts", new{count, offset});
|
||||
public async Task<BlogPost> GetLatestPostAsync() => await Get<BlogPost>("/getlatestpost");
|
||||
public async Task<int> GetCountAsync() => await Get<int>("/getcount");
|
||||
public async Task<BlogPost> GetPostByIdAsync(int id) => await Get<BlogPost>("/get/" + id);
|
||||
public async Task<BlogPost> SavePost(BlogPostSubmission post) => await Post<BlogPost>("/savepost", post);
|
||||
public async Task<IEnumerable<BlogPost>> GetAllPostsAsync() => await Get<IEnumerable<BlogPost>>("/getallposts");
|
||||
public async Task DeletePostAsync(int id) => await Post<object>("/deletepost", id);
|
||||
public async Task PublishPostAsync(int id) => await Post<object>("/publishpost", id);
|
||||
public async Task<BlogPost> GetPostByUrlAsync(string url) => await Get<BlogPost>("get/" + url);
|
||||
public async Task<IEnumerable<BlogPost>> GetLatestPostsAsync(int count = 0, int offset = 0) => await Get<IEnumerable<BlogPost>>("getlatestposts", new{count, offset});
|
||||
public async Task<BlogPost> GetLatestPostAsync() => await Get<BlogPost>("getlatestpost");
|
||||
public async Task<int> GetCountAsync() => await Get<int>("getcount");
|
||||
public async Task<BlogPost> GetPostByIdAsync(int id) => await Get<BlogPost>("get/" + id);
|
||||
public async Task<BlogPost> SavePost(BlogPostSubmission post) => await Post<BlogPost>("savepost", post);
|
||||
public async Task<IEnumerable<BlogPost>> GetAllPostsAsync() => await Get<IEnumerable<BlogPost>>("getallposts");
|
||||
public async Task DeletePostAsync(int id) => await Post<object>("deletepost", id);
|
||||
public async Task PublishPostAsync(int id) => await Post<object>("publishpost", id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
@ -47,7 +48,10 @@ namespace Website
|
|||
.AddSingleton<IBlogApi, BlogApi>()
|
||||
.AddSingleton<UserRepository, UserRepository>()
|
||||
.AddSingleton(new GitServerApi(new HttpClient(), Configuration["gitDomain"], Configuration["gitToken"]))
|
||||
.AddHttpClient<IBlogApi, BlogApi>(client => client.BaseAddress = new Uri(Configuration["blogApiEndpoint"]));
|
||||
.AddHttpClient<IBlogApi, BlogApi>(client => client.BaseAddress = new Uri(Configuration["blogApiEndpoint"]))
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler {
|
||||
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
|
||||
});
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue