cmd

package
v0.0.0-...-3cb022a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Main = gcmd.Command{
		Name:  "main",
		Usage: "main",
		Brief: "start http server",
		Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {

			SetLoggerDefaultHandler()
			s := g.Server()
			s.Use(
				service.Middleware().MiddlewareCORS,
				service.Middleware().Ctx,
				service.Middleware().I18NMiddleware,
				service.Middleware().ResponseHandler,
			)

			s.BindStatusHandler(404, func(r *ghttp.Request) {
				r.Response.Writeln("404 - 你似乎来到了没有知识存在的荒原…")
			})
			s.BindStatusHandler(403, func(r *ghttp.Request) {
				r.Response.Writeln("403 - 网站拒绝显示此网页")
			})

			s.Group("/", func(group *ghttp.RouterGroup) {

				group.Bind(
					controller.Hello,
					controller.User.Login,
					controller.Index.CategoryAndTag,
					controller.SiteSttings.Site,
					controller.Blog.NbBlogs,
					controller.Blog.NbBlogDetail,
					controller.Comment.Comment,
					controller.Comment.CommentList,
				)
			})
			s.Group("/", func(group *ghttp.RouterGroup) {
				group.Middleware(service.Middleware().TokenAuth)

				group.Bind(
					controller.Dashboart.Dashboart,
					controller.Tags.ShowTags,
					controller.Tags.AddTags,
					controller.Tags.UpdateTags,
					controller.Tags.DeleteTags,
					controller.Category.ShowCategory,
					controller.Category.AddCategory,
					controller.Category.UpdateCategory,
					controller.Category.DeleteCategory,
					controller.Blog.CreateBlog,
					controller.Blog.ShowBlogs,
					controller.Blog.UpdateBlog,
					controller.Blog.DeleteBlog,
					controller.Blog.BlogDetail,
					controller.Blog.UpdateBlogTop,
					controller.Blog.UpdateBlogRecommend,
					controller.Blog.UpdateBlogVisibilityReq,
					controller.Moment.CteatMomet,
					controller.Moment.ShoewMoments,
					controller.Moment.UpdatePublishedStatus,
					controller.Moment.MomoentDetil,
					controller.Moment.UpdateMoment,
					controller.Moment.DeleteMoment,
					controller.SiteSttings.SiteSettingsDetil,
					controller.SiteSttings.UpdateSiteSettings,
					controller.About.About,
					controller.About.UpdateAbout,
				)
			})
			s.Run()
			return nil
		},
	}
)

Functions

func SetLoggerDefaultHandler

func SetLoggerDefaultHandler()

SetLoggerDefaultHandler 替代默认的日志handler,禁止控制台输出,全部输出到文件

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL