mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
29 lines
513 B
Go
29 lines
513 B
Go
package workers
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"syscall/js"
|
|
)
|
|
|
|
type responseWriterBuffer struct {
|
|
header http.Header
|
|
statusCode int
|
|
*io.PipeReader
|
|
*io.PipeWriter
|
|
}
|
|
|
|
var _ http.ResponseWriter = &responseWriterBuffer{}
|
|
|
|
func (w responseWriterBuffer) Header() http.Header {
|
|
return w.header
|
|
}
|
|
|
|
func (w responseWriterBuffer) WriteHeader(statusCode int) {
|
|
w.statusCode = statusCode
|
|
}
|
|
|
|
func (w responseWriterBuffer) toJSResponse() (js.Value, error) {
|
|
return toJSResponse(w.PipeReader, w.statusCode, w.header)
|
|
}
|