From c93e236267c4d517861ec3db82c10f3f3961f62d Mon Sep 17 00:00:00 2001 From: Hermes Date: Tue, 23 Jun 2026 01:31:05 -0700 Subject: [PATCH] feat(server): REST + MCP routes (REST on :8310) --- server.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 server.go 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 +}