cmd

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: MIT 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) {
			s := g.Server()
			if gfile.Exists("./static/public/html/") {
				s.SetIndexFolder(true)
				s.SetServerRoot("./static/public/html/")
			} else {
				g.Log().Error(ctx, "./static/public/html/ directory is not exist")
			}

			s.Group("/", func(group *ghttp.RouterGroup) {
				group.Middleware(
					ghttp.MiddlewareHandlerResponse,
					middleware.GlobalExceptionMiddleware,
				)

				group.Group("/api", func(group *ghttp.RouterGroup) {
					group.Bind(
						controller.Hello,
						controller.Authentication,
						controller.Target,
						controller.AlertWebhook,
					)
				})

				group.Group("/api", func(group *ghttp.RouterGroup) {
					group.Middleware(
						middleware.TokenMiddleware,
					)
					group.Bind(
						controller.Group,
						controller.Node,
						controller.User,
						controller.Rules,
						controller.Config,
						controller.Alert,
					)
				})
			})

			s.Run()
			return nil
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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