vweb: replace ?string with string on Cookie struct

pull/10450/head
bettafish 2021-06-15 13:53:55 +02:00
parent 67100b45c3
commit e4065ed8d3
1 changed files with 4 additions and 8 deletions

View File

@ -90,8 +90,8 @@ pub struct Cookie {
name string name string
value string value string
expires time.Time expires time.Time
path ?string path string
domain ?string domain string
secure bool secure bool
http_only bool http_only bool
} }
@ -218,12 +218,8 @@ pub fn (mut ctx Context) enable_chunked_transfer(max_chunk_len int) {
// Sets a cookie // Sets a cookie
pub fn (mut ctx Context) set_cookie(cookie Cookie) { pub fn (mut ctx Context) set_cookie(cookie Cookie) {
mut cookie_data := []string{} mut cookie_data := []string{}
if path := cookie.path { cookie_data << 'path=$cookie.path;'
cookie_data << 'path=$path;' cookie_data << 'domain=$cookie.domain;'
}
if domain := cookie.domain {
cookie_data << 'domain=$domain;'
}
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 { ' ' }
cookie_data << secure cookie_data << secure