set Local to false...

This commit is contained in:
Adrien PONSIN 2025-04-15 21:40:46 +02:00
parent 143e4df5b2
commit 6a1242813b
No known key found for this signature in database
GPG Key ID: 7B4D4A32C05C475E

View File

@ -206,6 +206,33 @@ func (s serve) action(ctx context.Context, command *cli.Command) error {
if err != nil {
return err
}
/*
requests := command.StringSlice(addRequestsFlagName)
log.Info().Msgf("%d", len(requests))
if len(requests) > 0 {
clear(containerMethodRegex)
for _, request := range requests {
// An applicator is a container name/HTTP method pair e.g., nginx(GET).
// The following regex extracts this applicator and the associated URL regex.
aur := applicatorURLRegex.FindString(request)
if aur == "" {
// If we are here, it means that user set a wildcard (kinda) applicator e.g., GET,POST:URL_REGEX.
// In its extended form, this applicator can be read as follows: *(GET,POST):URL_REGEX.
methods, urlRegex, ok := strings.Cut(request, ":")
if !ok { // || methods == ""?
return errors.New("HTTP method(s) must be specified before ':'")
}
if err = registerMethodRegex("*", urlRegex, strings.Split(methods, ",")); err != nil {
return err
}
}
applicator, urlRegex, _ := strings.Cut(aur, ":")
if err = registerMethodRegex(containerNameRegex.FindString(applicator), urlRegex, httpMethodsRegex.FindAllString(applicator, -1)); err != nil {
return err
}
}
}
*/
var l net.Listener
l, err = net.Listen("tcp", ap.srvAddrPort.String())
if err != nil {
@ -417,10 +444,11 @@ func addRequests() cli.Flag {
Category: "network",
Usage: "add requests",
Sources: middleman.PluckEnvVar(EnvVarPrefix, addRequestsFlagName),
Local: true, // Required to trigger the Action when this flag is set via the environment variable, see https://github.com/urfave/cli/issues/2041.
// Local: true, // Required to trigger the Action when this flag is set via the environment variable, see https://github.com/urfave/cli/issues/2041.
Value: []string{"*:" + defaultAllowedRequest},
Aliases: middleman.PluckAlias(ServeCmd, addRequestsFlagName),
Action: func(ctx context.Context, command *cli.Command, requests []string) error {
log.Info().Msgf("%d", len(requests))
clear(containerMethodRegex)
for _, request := range requests {
// An applicator is a container name/HTTP method pair e.g., nginx(GET).