vweb: use http.Cookie
parent
66572d5ead
commit
a8461a900d
|
@ -2620,7 +2620,8 @@ pub fn (mut c Checker) ident(mut node ast.Ident) ast.Type {
|
||||||
if !name.contains('.') && node.mod != 'builtin' {
|
if !name.contains('.') && node.mod != 'builtin' {
|
||||||
name = '${node.mod}.$node.name'
|
name = '${node.mod}.$node.name'
|
||||||
}
|
}
|
||||||
if name == c.const_decl {
|
if name == c.const_decl && !c.pref.translated {
|
||||||
|
// TODO allow references, do not just check by name
|
||||||
c.error('cycle in constant `$c.const_decl`', node.pos)
|
c.error('cycle in constant `$c.const_decl`', node.pos)
|
||||||
return ast.void_type
|
return ast.void_type
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,14 +193,6 @@ pub fn (ctx Context) init_server() {
|
||||||
// Probably you can use it for check user session cookie or add header.
|
// Probably you can use it for check user session cookie or add header.
|
||||||
pub fn (ctx Context) before_request() {}
|
pub fn (ctx Context) before_request() {}
|
||||||
|
|
||||||
pub struct Cookie {
|
|
||||||
name string
|
|
||||||
value string
|
|
||||||
expires time.Time
|
|
||||||
secure bool
|
|
||||||
http_only bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// vweb intern function
|
// vweb intern function
|
||||||
[manualfree]
|
[manualfree]
|
||||||
pub fn (mut ctx Context) send_response_to_client(mimetype string, res string) bool {
|
pub fn (mut ctx Context) send_response_to_client(mimetype string, res string) bool {
|
||||||
|
@ -311,7 +303,7 @@ pub fn (mut ctx Context) not_found() Result {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets a cookie
|
// Sets a cookie
|
||||||
pub fn (mut ctx Context) set_cookie(cookie Cookie) {
|
pub fn (mut ctx Context) set_cookie(cookie http.Cookie) {
|
||||||
mut cookie_data := []string{}
|
mut cookie_data := []string{}
|
||||||
mut secure := if cookie.secure { 'Secure;' } else { '' }
|
mut secure := if cookie.secure { 'Secure;' } else { '' }
|
||||||
secure += if cookie.http_only { ' HttpOnly' } else { ' ' }
|
secure += if cookie.http_only { ' HttpOnly' } else { ' ' }
|
||||||
|
|
Loading…
Reference in New Issue