Song Liu,

On Mon, Apr 3, 2017 at 5:33 AM, Song Liu <[email protected]> wrote:

> Is there any other official way to cancel a ResponseWriter ?
>
> Many thanks.
>
> On Saturday, April 1, 2017 at 8:12:55 PM UTC+8, Song Liu wrote:
>>
>>
>> I am implementing a file server, so http.ServerFile used to write back the 
>> file content to remote client:
>>
>>
>> func downloadFile(w http.ResponseWriter, r *http.Request, p 
>> httprouter.Params) {
>>     ...
>>
>>     http.ServeFile(w, r, filePath)
>> }
>>
>>
>> But sometimes the server want to abort the downloading, so what's the way
>> to abort the ResponseWriter ?
>>
>>
that sounds like a job for context.Context.
check out this video:
 https://youtu.be/LSzR0VEraWw?list=PL64wiCrrxh4Jisi7OcCJIUpguV_f5jGnZ

hth,
-s

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to