#3135 - Add request duration to response details
This commit is contained in:
@@ -8,11 +8,23 @@ const Headers = ( { headers } )=>{
|
|||||||
<pre>{headers}</pre>
|
<pre>{headers}</pre>
|
||||||
</div>)
|
</div>)
|
||||||
}
|
}
|
||||||
|
|
||||||
Headers.propTypes = {
|
Headers.propTypes = {
|
||||||
headers: PropTypes.array.isRequired
|
headers: PropTypes.array.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Duration = ( { duration } ) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h5>Request duration</h5>
|
||||||
|
<pre>{duration} ms</pre>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Duration.propTypes = {
|
||||||
|
duration: PropTypes.number.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default class LiveResponse extends React.Component {
|
export default class LiveResponse extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
response: PropTypes.object.isRequired,
|
response: PropTypes.object.isRequired,
|
||||||
@@ -27,6 +39,7 @@ export default class LiveResponse extends React.Component {
|
|||||||
const headers = response.get("headers").toJS()
|
const headers = response.get("headers").toJS()
|
||||||
const notDocumented = response.get("notDocumented")
|
const notDocumented = response.get("notDocumented")
|
||||||
const isError = response.get("error")
|
const isError = response.get("error")
|
||||||
|
const duration = response.get("duration")
|
||||||
|
|
||||||
const body = isError ? response.get("response").get("text") : response.get("text")
|
const body = isError ? response.get("response").get("text") : response.get("text")
|
||||||
|
|
||||||
@@ -80,6 +93,9 @@ export default class LiveResponse extends React.Component {
|
|||||||
{
|
{
|
||||||
hasHeaders ? <Headers headers={ returnObject }/> : null
|
hasHeaders ? <Headers headers={ returnObject }/> : null
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
duration ? <Duration duration={ duration } /> : null
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -207,8 +207,14 @@ export const executeRequest = (req) => ({fn, specActions, specSelectors}) => {
|
|||||||
|
|
||||||
specActions.setRequest(req.pathName, req.method, parsedRequest)
|
specActions.setRequest(req.pathName, req.method, parsedRequest)
|
||||||
|
|
||||||
|
// track duration of request
|
||||||
|
const startTime = Date.now()
|
||||||
|
|
||||||
return fn.execute(req)
|
return fn.execute(req)
|
||||||
.then( res => specActions.setResponse(req.pathName, req.method, res))
|
.then( res => {
|
||||||
|
res.duration = Date.now() - startTime
|
||||||
|
specActions.setResponse(req.pathName, req.method, res)
|
||||||
|
} )
|
||||||
.catch( err => specActions.setResponse(req.pathName, req.method, { error: true, err: serializeError(err) } ) )
|
.catch( err => specActions.setResponse(req.pathName, req.method, { error: true, err: serializeError(err) } ) )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user