feat: add ax serve command with JSON API backed by NodeService
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
30
cmd/serve.go
Normal file
30
cmd/serve.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"axolotl/serve"
|
||||
"axolotl/service"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var serveCmd = &cobra.Command{
|
||||
Use: "serve",
|
||||
Short: "Start the JSON API server",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
sc := cfg.GetServerConfig()
|
||||
addr := fmt.Sprintf("%s:%d", sc.Host, sc.Port)
|
||||
handler := serve.New(service.GetNodeServiceForUser)
|
||||
fmt.Fprintf(os.Stdout, "listening on %s\n", addr)
|
||||
if err := http.ListenAndServe(addr, handler); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(serveCmd)
|
||||
}
|
||||
Reference in New Issue
Block a user