src/http/api/resources/dag.js
// main route handler which is called after the above `parseArgs`, but only if the args were valid
main route handler which is called after the above `parseArgs`, but only if the args were valid
main route handler which is called after the above ` parseArgs ` but only if the args were valid
async handler (request, h) {
    const {
      key,
      path
    } = request.pre.args
    const { ipfs } = request.server.app
    let dataEncoding = request.query['data-encoding']
    if (dataEncoding === 'text') {
      dataEncoding = 'utf8'
    }
    let result
    try {
      result = await ipfs.dag.get(key, path)
    } catch (err) {
      throw Boom.badRequest(err)
    }
    try {
      result.value = encodeBufferKeys(result.value, dataEncoding)
    } catch (err) {
      throw Boom.boomify(err)
    }
    return h.response(result.value)
  }
async handler ( request , h ) { const { key , path } = request . pre . args const { ipfs } = request . server . app let dataEncoding = request . query [ 'data-encoding' ] if ( dataEncoding === 'text' ) { dataEncoding = 'utf8' } let result try { result = await ipfs . dag . get ( key , path ) } catch ( err ) { throw Boom . badRequest ( err ) } try { result . value = encodeBufferKeys ( result . value , dataEncoding ) } catch ( err ) { throw Boom . boomify ( err ) } return h . response ( result . value ) }
main route handler which is called after the above `parseArgs`, but only if the args were valid
main route handler which is called after the above ` parseArgs ` but only if the args were valid