From a011f54361ce509d8c4ff7d36d62ce2a2cb3d03f Mon Sep 17 00:00:00 2001 From: Manuel Date: Wed, 1 Feb 2023 21:00:00 +0100 Subject: [PATCH] Minor tweaks & changes for latest vlang version --- src/config.v | 7 ++----- src/main.v | 4 ++-- src/web.v | 12 ++++++------ v.mod | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/config.v b/src/config.v index 82f5f26..45ef11c 100644 --- a/src/config.v +++ b/src/config.v @@ -41,9 +41,6 @@ fn load_config() !Config { } fn config_path() string { - path_env := $env('CONFIG_PATH') - if path_env.trim_space().len != 0 { - return path_env - } - return './config.toml' + path_env := $env('CONFIG_PATH').trim_space() + return if path_env.len != 0 { path_env } else { './config.toml' } } diff --git a/src/main.v b/src/main.v index 1960312..5f38925 100644 --- a/src/main.v +++ b/src/main.v @@ -1,7 +1,7 @@ module main import vweb -import sqlite +import db.sqlite import time import os @@ -43,7 +43,7 @@ fn main() { // } mut host := '::' - if app_config.host != '' { + if app_config.host.len != 0 { host = app_config.host } diff --git a/src/web.v b/src/web.v index e2fdb5c..57389d4 100644 --- a/src/web.v +++ b/src/web.v @@ -48,7 +48,7 @@ pub fn (mut app App) score_submit() vweb.Result { return app.json(Status{400, 'Bad JSON object'}) } - if body.player.trim_space() == '' { + if body.player.trim_space().len == 0 { app.set_status(400, '') return app.json(Status{400, 'Name cannot be empty'}) } @@ -70,16 +70,16 @@ pub fn (mut app App) score_submit() vweb.Result { } ['/api/v1/score/list'; options] -pub fn (mut app App) handle_score_list_cors() vweb.Result { - return app.handle_cors() +pub fn (mut app App) handle_score_list_options() vweb.Result { + return app.handle_options() } ['/api/v1/score/submit'; options] -pub fn (mut app App) handle_score_submit_cors() vweb.Result { - return app.handle_cors() +pub fn (mut app App) handle_score_submit_options() vweb.Result { + return app.handle_options() } -fn (mut app App) handle_cors() vweb.Result { +fn (mut app App) handle_options() vweb.Result { app.set_status(204, '') app.add_cors_headers() return app.ok('') diff --git a/v.mod b/v.mod index d9b470c..d94ae67 100644 --- a/v.mod +++ b/v.mod @@ -1,7 +1,7 @@ Module { name: 'highscore-server' description: 'A generic highscore server for a game' - version: '1.0.0' + version: '1.1' license: 'AGPLv3-only' repo_url: 'https://git.snrd.eu/sunred/highscore-server' vcs: 'git'