huhubun / bunblog.api Goto Github PK
View Code? Open in Web Editor NEWBun Blog API
Home Page: https://bun.plus
License: MIT License
Bun Blog API
Home Page: https://bun.plus
License: MIT License
Why choose Semantic UI
Add popup notification by Kendo Notification
TempData
GET /informations
: Add system version(such as Debian 9, Windows 10) and runtime version(3.0.0-preview9) to the response bodyLogging to
Bun.Blog.Web
to Bun.Blog.Web.Admin
Bun.Blog.Web
project with asp.net core 2.0 and Angular4Move authentication business logic code from controller to service layer.
2020-04-19 21:51:06.0855||ERROR|ExceptionHandler|url: http://localhost/api/posts/7|action: |0HLV4C5EMHMUA:00000004| AutoMapper.AutoMapperMappingException: Error mapping types.
Mapping types:
Post -> BlogPostModel
BunBlog.Core.Domain.Posts.Post -> BunBlog.API.Models.Posts.BlogPostModel
Type Map configuration:
Post -> BlogPostModel
BunBlog.Core.Domain.Posts.Post -> BunBlog.API.Models.Posts.BlogPostModel
Destination Member:
MetadataList
---> System.InvalidOperationException: A second operation started on this context before a previous operation completed. This is usually caused by different threads using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.
at Microsoft.EntityFrameworkCore.Internal.ConcurrencyDetector.EnterCriticalSection()
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.Load[TSource](IQueryable`1 source)
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.Load(INavigation navigation, InternalEntityEntry entry)
at Microsoft.EntityFrameworkCore.Internal.LazyLoader.Load(Object entity, String navigationName)
at Microsoft.EntityFrameworkCore.Proxies.Internal.LazyLoadingInterceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.PostProxy.get_MetadataList()
at lambda_method(Closure , PostProxy , BlogPostModel , ResolutionContext )
--- End of inner exception stack trace ---
at lambda_method(Closure , PostProxy , BlogPostModel , ResolutionContext )
at lambda_method(Closure , Object , Object , ResolutionContext )
at BunBlog.API.Controllers.PostsController.GetAsync(Int32 id) in E:\Project\Github\BunBlog.API\src\BunBlog.API\Controllers\PostsController.cs:line 91
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
At the beginning of the project, BunBlog only supports postgresql(#5), but in the future it will support multiple databases.
This is caused by memory cache
Use docker on Staging
and Production
environment
Modify
POST /posts
Added PostType
parameter to distinguish between publishing and saving draftsNew
PUT /posts/{linkName}/draft
DELETE /posts/{linkName}/draft
Route:
app.UseMvc(routes =>
{
routes
.MapRoute(
name: "Web",
template: "{controller=Home}/{action=Index}"
)
.MapAdminRoute();
});
Area route:
public static class IRouteBuilderExtensions
{
public static IRouteBuilder MapAdminRoute(this IRouteBuilder routeBuilder)
{
return routeBuilder
.MapAdminAreaRoute(
name: "Admin",
url: "{controller=Dashboard}/{action=Index}/{id?}"
)
.MapAdminAreaRoute(
name: "Dashboard",
url: "Dashboard",
defaults: new { controller = "Dashboard", action = "Index" }
)
.MapAdminAreaRoute(
name: "PostList",
url: "Post/{action}",
defaults: new { controller = "Post", action = "List" }
)
.MapAdminAreaRoute(
name: "EditPost",
url: "Post/Edit/{id:int}",
defaults: new { controller = "Post", action = "Edit" }
);
}
private static IRouteBuilder MapAdminAreaRoute(this IRouteBuilder routeBuilder, string name, string url)
{
return routeBuilder.MapAdminAreaRoute(name, url, null /* defaults */);
}
private static IRouteBuilder MapAdminAreaRoute(this IRouteBuilder routeBuilder, string name, string url, object defaults)
{
return routeBuilder.MapAreaRoute(name, "Admin", "Admin/" + url, defaults);
}
}
/Home/Index:
@* returns null *@
@Url.RouteUrl("Dashboard")
/Admin/Post/List:
@* returns /Post/List *@
@Url.RouteUrl("Web")
Why 😞 😞
GET /posts/{linkName}/v{version}
Configure the listening address into appsettings.json
refresh_thoek
获取新 token 功能
POST /authentication/token
协议access_token
放置在 Authorization
头中。后台仍然需要验证该 access_token
除有效期外的合法性,并从中获取用户名{"grant_type": "refresh_token", "refresh_token": "{{refresh_token}}"}
password
获取 token 时一致refresh_thoek
刷新后,原 refresh_thoek
将失效GET /authentication/endsession
协议204
access_token
将失效GET /authentication/user
协议200
{ userName: "user_id" }
When change the linkName with PUT /api/tags/{linkName}
and PUT /api/categories
, always returns a 400 error.
Request: PUT /api/tags/test
{
"linkName": "test-a", <-- use a different linkName
"displayName": "test tag"
}
Response:
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "Bad Request",
"status": 400,
"traceId": "0HLOQGN6QSAOG:00000004"
}
GET api/information
bool IsOnKubernetes
propertyhttps://docs.microsoft.com/zh-cn/aspnet/core/publishing/web-publishing-vs#excluding-files
I want to skip wwwroot\lib
folder, and use <MsDeploySkipRules>
. I add
<ItemGroup>
<MsDeploySkipRules Include="CustomSkipFolder">
<ObjectName>dirPath</ObjectName>
<AbsolutePath>wwwroot\lib</AbsolutePath>
</MsDeploySkipRules>
</ItemGroup>
to Bun.Blog.Web.csproj
, but it doesn't work, wwwroot\lib
still be published.
But <Content>
is possible:
<ItemGroup>
<Content Update="wwwroot/lib/**/*.*" CopyToPublishDirectory="Never" />
</ItemGroup>
I want to know why <MsDeploySkipRules>
not work ❓
SiteLink
GET /siteLinks
GET /siteLinks/{id}
POST /siteLinks
PUT /siteLinks/{id}
DELETE /siteLinks/{id}
Setting
tableblogSettingResources.json
. This design can easily add setting items without modifying the program. If we want to use the new settings in the UI, just modify the file directly.GET /settings
Get settings listPUT /settings/{code}
Modify the specified settingsA declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.