feat(server): REST + MCP routes (REST on :8310)

This commit is contained in:
Hermes 2026-06-23 01:31:05 -07:00
parent 9635140be9
commit c93e236267

28
server.go Normal file
View file

@ -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
}