| 1259 | } |
| 1260 | |
| 1261 | func quitquitquit(quitOnce *sync.Once, shutdownCh chan<- error) http.HandlerFunc { |
| 1262 | return func(rw http.ResponseWriter, req *http.Request) { |
| 1263 | if req.Method != http.MethodPost && req.Method != http.MethodGet { |
| 1264 | rw.WriteHeader(400) |
| 1265 | return |
| 1266 | } |
| 1267 | quitOnce.Do(func() { |
| 1268 | select { |
| 1269 | case shutdownCh <- errQuitQuitQuit: |
| 1270 | default: |
| 1271 | // The write attempt to shutdownCh failed and |
| 1272 | // the proxy is already exiting. |
| 1273 | } |
| 1274 | }) |
| 1275 | } |
| 1276 | } |
| 1277 | |
| 1278 | func startHTTPServer(ctx context.Context, l cloudsql.Logger, addr string, mux *http.ServeMux, shutdownCh chan<- error) { |
| 1279 | server := &http.Server{ |