-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethods_server.go
More file actions
32 lines (28 loc) · 1.28 KB
/
Copy pathmethods_server.go
File metadata and controls
32 lines (28 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import "runtime"
var capabilityMethods = []string{
"server.ping", "server.version", "server.capabilities", methodShutdown,
"files.list", "files.validate", "files.stat", "files.read", "files.extract_tar",
"git.info", "git.status", "git.list_branches", "git.worktree_create", "git.worktree_remove",
"process.spawn", "process.stdin", "process.kill", "process.killAndWait", "process.reattach",
}
// capabilityFeatures advertises optional protocol extensions. Added by the
// reference daemon in 7c2f88d; the sole entry is the stdin-offset idempotency
// contract (see process.stdin / stdinResult). Always emitted.
var capabilityFeatures = []string{"process.stdin.offset"}
func (s *server) handleServer(c *conn, req *request) *response {
switch req.Method {
case "server.ping":
return ptr(okResult(req.ID, pongResult{Pong: true}))
case "server.version":
return ptr(okResult(req.ID, versionResult{Version: Version, Platform: runtime.GOOS, Arch: runtime.GOARCH}))
case "server.capabilities":
return ptr(okResult(req.ID, capabilitiesResult{Version: Version, Methods: capabilityMethods, Features: capabilityFeatures}))
case methodShutdown:
// No response is sent: the daemon stops and the connection closes.
s.signalShutdown()
return nil
default:
return ptr(unknownMethod(req))
}
}