diff --git a/server.go b/server.go new file mode 100644 index 0000000..8ea2b03 --- /dev/null +++ b/server.go @@ -0,0 +1,28 @@ +package main + +import ( + "net/http" +) + +// Server — the HTTP/MCP server. Both surfaces (REST on :8310, MCP on :8320) +// share the same Store. +type Server struct { + store *Store +} + +func NewServer(store *Store) *Server { + return &Server{store: store} +} + +// Routes — the REST API surface. Per docs/API.md. +func (s *Server) Routes() *http.ServeMux { + mux := http.NewServeMux() + mux.HandleFunc("GET /api/healthz", s.handleHealth) + mux.HandleFunc("GET /api/posts", s.handleListPosts) + mux.HandleFunc("POST /api/posts", s.handleCreatePost) + mux.HandleFunc("POST /api/authors", s.handleUpsertAuthor) + mux.HandleFunc("POST /api/channels", s.handleUpsertChannel) + mux.HandleFunc("GET /api/posts/{id}", s.handleGetPost) + mux.HandleFunc("POST /api/posts/{id}/comments", s.handleCreateComment) + return mux +}