1package tinyclient23import (4 "net/http"5 "strings"6)78// handleControlRoute dispatches endpoints that mutate or stream management9// state. Keeping these together makes their authentication and HTTP method10// requirements visible without mixing them into page and asset routing.11func (a *App) handleControlRoute(writer http.ResponseWriter, request *http.Request) bool {12 switch {13 case request.Method == http.MethodPost && request.URL.Path == "/manage/rpc":14 a.rpc(writer, request)15 case request.Method == http.MethodGet && request.URL.Path == "/api/join-policy":16 a.joinPolicy(writer)17 case request.Method == http.MethodPost && request.URL.Path == "/api/invites/claim":18 a.claimInvite(writer, request)19 case request.Method == http.MethodGet && request.URL.Path == "/manage/jobs/status":20 a.jobStatus(writer, request)21 default:22 return false23 }24 return true25}2627// handleBrowseRoute dispatches authenticated browse pages and compatibility28// redirects. API and asset endpoints remain in the public route group.29func (a *App) handleBrowseRoute(writer http.ResponseWriter, request *http.Request) bool {30 if request.URL.Path == "/manage/status" || request.URL.Path == "/tools" {31 http.Redirect(writer, request, requestPrefix(request)+"/manage/health", http.StatusMovedPermanently)32 return true33 }34 if request.Method == http.MethodGet && isBrowsePath(request.URL.Path) {35 a.browse(writer, request)36 return true37 }38 if request.URL.Path == "/share" {39 http.Redirect(writer, request, requestPrefix(request)+"/files", http.StatusSeeOther)40 return true41 }42 return false43}4445func isBrowsePath(path string) bool {46 return path == "/repos" || parseRepoRoute(path).ok || path == "/files" || filesView(path) != "" || fileHash(path) != "" ||47 path == "/approvals" || approvalID(path) != "" || path == "/profile" || path == "/wiki" ||48 strings.HasPrefix(path, "/wiki/") || path == "/manage/health" || roomRoute(path).tab != ""49}5051// handleWebMCPRoute dispatches the browser-facing query bridge separately52// from HTML pages so its contract can evolve independently.53func (a *App) handleWebMCPRoute(writer http.ResponseWriter, request *http.Request) bool {54 if request.Method != http.MethodGet {55 return false56 }57 switch request.URL.Path {58 case "/webmcp.js":59 a.webMCP(writer, request)60 case "/webmcp/query":61 a.webMCPQuery(writer, request)62 default:63 return false64 }65 return true66}