vweb: use http.Cookie

Alexander Medvednikov 2022-06-04 06:52:46 +03:00 committed by Chewing_Bever
parent bff84aab59
commit 8bb2ccfdbc
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 3 additions and 10 deletions

View File

@ -2620,7 +2620,8 @@ pub fn (mut c Checker) ident(mut node ast.Ident) ast.Type {
if !name.contains('.') && node.mod != 'builtin' {
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)
return ast.void_type
}

View File

@ -193,14 +193,6 @@ pub fn (ctx Context) init_server() {
// Probably you can use it for check user session cookie or add header.
pub fn (ctx Context) before_request() {}
pub struct Cookie {
name string
value string
expires time.Time
secure bool
http_only bool
}
// vweb intern function
[manualfree]
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
pub fn (mut ctx Context) set_cookie(cookie Cookie) {
pub fn (mut ctx Context) set_cookie(cookie http.Cookie) {
mut cookie_data := []string{}
mut secure := if cookie.secure { 'Secure;' } else { '' }
secure += if cookie.http_only { ' HttpOnly' } else { ' ' }