From a8461a900d9487cf0103d3e2057742ede46ed45b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 4 Jun 2022 06:52:46 +0300 Subject: [PATCH] vweb: use http.Cookie --- vlib/v/checker/checker.v | 3 ++- vlib/vweb/vweb.v | 10 +--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 9721273807..624e2ccc70 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 } diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 0619b75aaf..6fb12c7234 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -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 { ' ' }