github.com/blend/go-sdk@v1.20220411.3/r2/event_option.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package r2 9 10 import ( 11 "net/http" 12 "time" 13 ) 14 15 // EventOption is an event option. 16 type EventOption func(e *Event) 17 18 // OptEventRequest sets the response. 19 func OptEventRequest(req *http.Request) EventOption { 20 return func(e *Event) { 21 e.Request = req 22 } 23 } 24 25 // OptEventResponse sets the response. 26 func OptEventResponse(res *http.Response) EventOption { 27 return func(e *Event) { 28 e.Response = res 29 } 30 } 31 32 // OptEventElapsed sets the elapsed time. 33 func OptEventElapsed(elapsed time.Duration) EventOption { 34 return func(e *Event) { 35 e.Elapsed = elapsed 36 } 37 } 38 39 // OptEventBody sets the body. 40 func OptEventBody(body []byte) EventOption { 41 return func(e *Event) { 42 e.Body = body 43 } 44 }