Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): hex recognition the template type #212

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/static/server_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ func serverFlags() []cli.Flag {
&cli.StringSliceFlag{Name: consts.Pass, Usage: "Pass param to hz or Kitex."},
&cli.BoolFlag{Name: consts.Verbose, Usage: "Turn on verbose mode."},
&cli.BoolFlag{Name: consts.HexTag, Usage: "Add HTTP listen for Kitex.", Destination: &globalArgs.Hex},
&cli.StringFlag{Name: consts.HertzTemplate, Usage: "When using--hex, specify the Hertz template", Destination: &globalArgs.ServerArgument.HertzTemplate},
&cli.StringFlag{Name: consts.KitexTemplate, Usage: "When using--hex, specify the Kitex template", Destination: &globalArgs.ServerArgument.KitexTemplate},
}
}
3 changes: 3 additions & 0 deletions config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type ServerArgument struct {
GoSrc string
GoPkg string
GoPath string

KitexTemplate string
HertzTemplate string
}

type CommonParam struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/consts/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ const (
TypeTag = "type_tag"
HexTag = "hex"
SQLDir = "sql_dir"

HertzTemplate = "hertz_template"
KitexTemplate = "kitex_template"
)

const (
Expand Down
4 changes: 4 additions & 0 deletions pkg/server/hz.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func convertHzArgument(sa *config.ServerArgument, hzArgument *hzConfig.Argument)
return fmt.Errorf("idl path %s is not absolute", sa.IdlPath)
}

if sa.HertzTemplate != "" {
sa.Template = sa.HertzTemplate
}

if strings.HasSuffix(sa.Template, consts.SuffixGit) {
err = utils.GitClone(sa.Template, path.Join(tpl.HertzDir, consts.Server))
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/server/kitex.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ Flags:
return
}

if sa.KitexTemplate != "" {
sa.Template = sa.KitexTemplate
}

// Non-standard template
if strings.HasSuffix(sa.Template, consts.SuffixGit) {
err = utils.GitClone(sa.Template, path.Join(tpl.KitexDir, consts.Server))
Expand Down
Loading