From 6245876806523cb572c259f7fa059eb0e4387a62 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 16 Jul 2020 00:48:10 +0200 Subject: [PATCH] vweb: ip() --- .github/workflows/ci.yml | 1 + vlib/sqlite/sqlite.v | 3 ++- vlib/vweb/vweb.v | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc2a392d94..42b919c5e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,6 +50,7 @@ jobs: ./v vet vlib/v/ast ./v vet vlib/v/gen/cgen.v ./v vet vlib/v/checker + ./v vet vlib/sqlite # - name: Test v binaries # run: ./v -silent build-vbinaries diff --git a/vlib/sqlite/sqlite.v b/vlib/sqlite/sqlite.v index 21299ae581..0f7d04c79b 100644 --- a/vlib/sqlite/sqlite.v +++ b/vlib/sqlite/sqlite.v @@ -61,7 +61,7 @@ fn (db DB) init_stmt(query string) &C.sqlite3_stmt { fn get_int_from_stmt(stmt &C.sqlite3_stmt) int { x := C.sqlite3_step(stmt) if x != C.SQLITE_OK && x != C.SQLITE_DONE { - C.puts( C.sqlite3_errstr(x) ) + C.puts(C.sqlite3_errstr(x)) } res := C.sqlite3_column_int(stmt, 0) C.sqlite3_finalize(stmt) @@ -101,6 +101,7 @@ pub fn (db DB) exec(query string) ([]Row,int) { res = C.sqlite3_step(stmt) // Result Code SQLITE_ROW; Another row is available if res != 100 { + //C.puts(C.sqlite3_errstr(res)) break } mut row := Row{} diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index e30cd90270..5abb934891 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -507,6 +507,12 @@ pub fn (mut ctx Context) serve_static(url, file_path, mime_type string) { ctx.static_mime_types[url] = mime_type } +pub fn (ctx &Context) ip() string { + // TODO make return ctx.conn.peer_ip() or { '' } work + res := ctx.conn.peer_ip() or { '' } + return res +} + pub fn (mut ctx Context) error(s string) { ctx.form_error = s }