-
Notifications
You must be signed in to change notification settings - Fork 1
/
requestwriter.go
50 lines (40 loc) · 1.04 KB
/
requestwriter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package jaws
import (
"io"
"net/http"
)
type RequestWriter struct {
rq *Request
io.Writer
}
func (rw RequestWriter) UI(ui UI, params ...any) error {
return rw.rq.NewElement(ui).JawsRender(rw, params)
}
func (rw RequestWriter) Write(p []byte) (n int, err error) {
rw.rq.rendering.Store(true)
return rw.Writer.Write(p)
}
// Request returns the current jaws.Request.
func (rw RequestWriter) Request() *Request {
return rw.rq
}
// Initial returns the initial http.Request.
func (rw RequestWriter) Initial() *http.Request {
return rw.Request().Initial()
}
// HeadHTML outputs the HTML code needed in the HEAD section.
func (rw RequestWriter) HeadHTML() error {
return rw.Request().HeadHTML(rw)
}
// Session returns the Requests's Session, or nil.
func (rw RequestWriter) Session() *Session {
return rw.Request().Session()
}
// Get calls Request().Get()
func (rw RequestWriter) Get(key string) (val any) {
return rw.Request().Get(key)
}
// Set calls Request().Set()
func (rw RequestWriter) Set(key string, val any) {
rw.Request().Set(key, val)
}