MCPcopy Create free account
hub / github.com/github/docs / doPost

Method doPost

lib/hydro.js:100–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98 const agent = getHttpsAgent()
99
100 const doPost = async () => {
101 // We *could* exit early on this whole `publish()` method if we know
102 // we're going to "mock" Hydro anyway, but injecting here, before
103 // the actual network operation, we make most of this method's code
104 // execute without actually depending on real network. This is
105 // good for any functional tests that depend on this, e.g. jest tests.
106 if (MOCK_HYDRO_POST && !this.forceDisableMock) {
107 return { statusCode: 200 }
108 }
109 return got(this.endpoint, {
110 method: 'POST',
111 body,
112 headers: {
113 Authorization: `Hydro ${token}`,
114 'Content-Type': 'application/json',
115 'X-Hydro-App': 'docs-production',
116 },
117 // Because we prefer to handle the status code manually below
118 throwHttpErrors: false,
119 agent: {
120 // Deliberately not setting up a `http` or `http2` agent
121 // because it won't be used for this particular `got` request.
122 https: agent,
123 },
124 // See above, where these are configured for the explanation
125 retry: retryConfiguration,
126 timeout: timeoutConfiguration,
127 })
128 }
129
130 const res = await statsd.asyncTimer(doPost, 'hydro.response_time')()
131

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected