httpapi

package
v0.1.6-alpha4 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CMD = func() *cli.Command {

	var name string // 名称
	var addr string // 监听地址
	var instanceID int

	return &cli.Command{
		Name:  "http",
		Usage: "create a http api",
		Action: func(ctx *cli.Context) error {
			if name == "" {
				return errors.New("must a name")
			}

			if err := os.MkdirAll(filepath.Join("internal", "api", name), os.ModePerm); err != nil {
				return err
			}

			if err := createMainFile(name, addr, instanceID); err != nil {
				return err
			}

			if err := createConfigYaml(name); err != nil {
				return err
			}

			gomodCmd := exec.Command("go", "mod", "tidy")
			_, err := gomodCmd.Output()
			if err != nil {
				return err
			}

			return nil
		},
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:        "name, n",
				Usage:       "http api name",
				Destination: &name,
			},
			&cli.StringFlag{
				Name:        "addr, a",
				Usage:       "http api listen address",
				Destination: &addr,
				Value:       "127.0.0.1:8080",
			},
			&cli.IntFlag{
				Name:        "id, i",
				Usage:       "http api intance id",
				Destination: &instanceID,
				Value:       1,
			},
		},
	}
}

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