Download this file
| 1 | package instancectl |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "net" |
| 6 | "net/http" |
| 7 | ) |
| 8 | |
| 9 | type requestConnKey struct{} |
| 10 | |
| 11 | func RequestConn(ctx context.Context) net.Conn { |
| 12 | c, _ := ctx.Value(requestConnKey{}).(net.Conn) |
| 13 | return c |
| 14 | } |
| 15 | func requestConnContext(ctx context.Context, c net.Conn) context.Context { |
| 16 | return context.WithValue(ctx, requestConnKey{}, c) |
| 17 | } |
| 18 | |
| 19 | // RunWithClaim serves the claim verbs through handler and, when |
| 20 | // heldRelease is not nil, the moves held-release route through it (the |
| 21 | // host passes it only with both flags on; nil leaves the route absent). |
| 22 | func RunWithClaim(args []string, handler, heldRelease http.Handler, hostApp func(string) (string, string, error)) { |
| 23 | runWithClaim(args, handler, heldRelease, hostApp) |
| 24 | } |
| 25 | |