Added API Endpoint and Admin Dashboard Endpoint

This commit is contained in:
2026-05-26 15:52:59 +02:00
parent 48f62500d5
commit 8ec5472355
7 changed files with 368 additions and 8 deletions
+20 -3
View File
@@ -1,14 +1,31 @@
package cmd
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/spf13/cobra"
"printer.backend/internal/server"
)
var serveCmd = &cobra.Command{
Use: "serve",
Short: "Start the HTTP server",
Run: func(cmd *cobra.Command, args []string) {
// TODO: implement server
Short: "Start API and admin dashboard HTTP servers",
RunE: func(cmd *cobra.Command, args []string) error {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
cmd.Printf("API: http://%s\n", cfg.APIAddr())
cmd.Printf("Admin: http://%s\n", cfg.AdminAddr())
if err := server.Run(ctx, cfg); err != nil {
return fmt.Errorf("server: %w", err)
}
cmd.Println("Server beendet.")
return nil
},
}