Files
kontor/kontor-gin/internal/cmd/check.go
T
tpeetz 2d6fa7b7ee
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
add rest client
2026-09-27 03:09:22 +02:00

61 lines
1.3 KiB
Go

package cmd
import (
"log/slog"
"github.com/spf13/cobra"
"resty.dev/v3"
)
type Login struct {
Email string
Password string
}
type LoginResponse struct {
Token string
}
var checkCmd = &cobra.Command{
Use: "check",
Short: "Check Kontor Database",
Long: "Check Kontor Database to given file",
// Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
slog.Info("check kontor")
slog.Info("Verbosity level", "level", verbose)
var login LoginResponse
client := resty.New()
res, err := client.R().
SetBody(Login{
Email: "thomas.peetz@thpeetz.de",
Password: "admin",
}).
SetHeader("Accept", "application/json").
SetResult(&login).
Post("http://127.0.0.1:8550/api/login")
if err != nil {
slog.Info("Health", "error", err.Error())
}
slog.Info("health", "token", login.Token)
res, err = client.R().
SetAuthToken(login.Token).
SetHeader("Accept", "application/json").
Get("http://127.0.0.1:8550/api/v1/comics/comics")
if err != nil {
slog.Info("comics", "error", err.Error())
}
slog.Info("comics", "res", res)
defer client.Close()
slog.Info("kontor.check_kontor.check_duplicate_links")
// check_duplicate_links(first_server, dirs)
slog.Info("kontor.check_kontor.check_media_dirs")
// check_media_dirs(first_server, dirs)
},
}
func init() {
rootCmd.AddCommand(checkCmd)
}