Init world. Basic registry API server
Work in progress . This commit adds the core registry service implementation with methods to: - Retrieve all registry entries - List entries with cursor-based pagination - Fetch specific server details by ID
This commit is contained in:
parent
2e8c761edf
commit
4fb5bc477e
1 changed files with 1702 additions and 2 deletions
48
internal/api/server.go
Normal file
48
internal/api/server.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/modelcontextprotocol/registry/internal/api/router"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
"github.com/modelcontextprotocol/registry/internal/service"
|
||||
)
|
||||
|
||||
// Server represents the HTTP server
|
||||
type Server struct {
|
||||
config *config.Config
|
||||
registry service.RegistryService
|
||||
router *http.ServeMux
|
||||
server *http.Server
|
||||
}
|
||||
|
||||
// NewServer creates a new HTTP server
|
||||
func NewServer(cfg *config.Config, registryService service.RegistryService) *Server {
|
||||
// Create router with all API versions registered
|
||||
mux := router.New(cfg, registryService)
|
||||
|
||||
server := &Server{
|
||||
config: cfg,
|
||||
registry: registryService,
|
||||
router: mux,
|
||||
server: &http.Server{
|
||||
Addr: cfg.ServerAddress,
|
||||
Handler: mux,
|
||||
},
|
||||
}
|
||||
|
||||
return server
|
||||
}
|
||||
|
||||
// Start begins listening for incoming HTTP requests
|
||||
func (s *Server) Start() error {
|
||||
log.Printf("HTTP server starting on %s", s.config.ServerAddress)
|
||||
return s.server.ListenAndServe()
|
||||
}
|
||||
|
||||
// Shutdown gracefully shuts down the server
|
||||
func (s *Server) Shutdown(ctx context.Context) error {
|
||||
return s.server.Shutdown(ctx)
|
||||
}
|
||||
Loading…
Reference in a new issue