Fixed linter errors and fixed tests
- Added error handling for JSON encoding in ServersHandler and ServersDetailHandler. - Updated test cases to reflect changes in handler functions and improved mock expectations. - Refactored server initialization to include ReadHeaderTimeout for better request handling. - Modified GitHubDeviceAuth to accept context in ValidateToken and checkOrgMembership methods. - Improved error messages in database import functions for better debugging. - Updated memory and mongo database list functions to accept context and improved filtering logic. - Enhanced logging in publisher tool for better visibility during execution. - Cleaned up code formatting and comments for better readability and maintainability.
This commit is contained in:
parent
c74a7af000
commit
b6c141a721
1 changed files with 317 additions and 225 deletions
|
|
@ -2,8 +2,8 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -25,9 +25,9 @@ func main() {
|
|||
|
||||
// Show version information if requested
|
||||
if *showVersion {
|
||||
fmt.Printf("MCP Registry v%s\n", Version)
|
||||
fmt.Printf("Git commit: %s\n", GitCommit)
|
||||
fmt.Printf("Build time: %s\n", BuildTime)
|
||||
log.Printf("MCP Registry v%s\n", Version)
|
||||
log.Printf("Git commit: %s\n", GitCommit)
|
||||
log.Printf("Build time: %s\n", BuildTime)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +47,8 @@ func main() {
|
|||
// Connect to MongoDB
|
||||
mongoDB, err := database.NewMongoDB(ctx, cfg.DatabaseURL, cfg.DatabaseName, cfg.CollectionName)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to connect to MongoDB: %v", err)
|
||||
log.Printf("Failed to connect to MongoDB: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Create registry service with MongoDB
|
||||
|
|
@ -66,7 +67,9 @@ func main() {
|
|||
|
||||
if cfg.SeedImport {
|
||||
log.Println("Importing data...")
|
||||
database.ImportSeedFile(mongoDB, cfg.SeedFilePath)
|
||||
if err := database.ImportSeedFile(mongoDB, cfg.SeedFilePath); err != nil {
|
||||
log.Printf("Failed to import seed file: %v", err)
|
||||
}
|
||||
log.Println("Data import completed successfully")
|
||||
}
|
||||
|
||||
|
|
@ -78,8 +81,9 @@ func main() {
|
|||
|
||||
// Start server in a goroutine so it doesn't block signal handling
|
||||
go func() {
|
||||
if err := server.Start(); err != nil && err != http.ErrServerClosed {
|
||||
log.Fatalf("Failed to start server: %v", err)
|
||||
if err := server.Start(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Printf("Failed to start server: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
@ -96,7 +100,7 @@ func main() {
|
|||
|
||||
// Gracefully shutdown the server
|
||||
if err := server.Shutdown(sctx); err != nil {
|
||||
log.Fatalf("Server forced to shutdown: %v", err)
|
||||
log.Printf("Server forced to shutdown: %v", err)
|
||||
}
|
||||
|
||||
log.Println("Server exiting")
|
||||
|
|
|
|||
Loading…
Reference in a new issue