feat(server): REST + MCP routes (REST on :8310)
This commit is contained in:
parent
9635140be9
commit
c93e236267
1 changed files with 28 additions and 0 deletions
28
server.go
Normal file
28
server.go
Normal 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
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue