working commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||
*/
|
||||
package servcmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"mproxy/pkg/servcli"
|
||||
)
|
||||
|
||||
// GetHello
|
||||
type GetHelloParams struct {
|
||||
Address string
|
||||
}
|
||||
|
||||
func (util *ServiceUtil) GetHello(cmd *cobra.Command, args []string) {
|
||||
util.getHelloParams.Address = args[0]
|
||||
res, err := util.getHello(&util.commonServiceParams, &util.getHelloParams)
|
||||
printResponse(res, err)
|
||||
}
|
||||
|
||||
type GetHelloResult struct{}
|
||||
|
||||
func (util *ServiceUtil) getHello(common *CommonServiceParams, params *GetHelloParams) (*GetHelloResult, error) {
|
||||
var err error
|
||||
res := &GetHelloResult{}
|
||||
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
ref, err := servcli.ParsePath(params.Address)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
ref.SetUserinfo(common.Username, common.Password)
|
||||
mw := servcli.NewBasicAuthMiddleware(ref.Userinfo())
|
||||
cli := servcli.NewClient(nil, mw)
|
||||
err = cli.GetHello(ctx, ref.Raw())
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user