Skip to content

Instantly share code, notes, and snippets.

@mnightingale
Created January 13, 2024 20:54
Show Gist options
  • Save mnightingale/0d917379b28a1bf0cad965bd4d34beb8 to your computer and use it in GitHub Desktop.
Save mnightingale/0d917379b28a1bf0cad965bd4d34beb8 to your computer and use it in GitHub Desktop.
rapidyenc decoder example
if resp.StatusCode/200 == 1 {
dec := rapidyenc.AcquireDecoder()
dec.SetReader(resp.Body)
request.Body = bytebufferpool.Get()
_, err := io.Copy(request.Body, dec)
// TODO: may want to ignore some errors and use partial data
if err != nil {
bytebufferpool.Put(request.Body)
request.Body = nil
rapidyenc.ReleaseDecoder(dec)
return err
}
meta := dec.Meta()
rapidyenc.ReleaseDecoder(dec)
request.File.Size = meta.Size
request.Filename = meta.Name
request.Offset = meta.Begin
request.CRC = meta.Hash
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment