Minor tweaks & changes for latest vlang version

This commit is contained in:
Manuel 2023-02-01 21:00:00 +01:00
parent 24a9cdc8cf
commit a011f54361
Signed by: SunRed
GPG Key ID: 4085037435E1F07A
4 changed files with 11 additions and 14 deletions

View File

@ -41,9 +41,6 @@ fn load_config() !Config {
} }
fn config_path() string { fn config_path() string {
path_env := $env('CONFIG_PATH') path_env := $env('CONFIG_PATH').trim_space()
if path_env.trim_space().len != 0 { return if path_env.len != 0 { path_env } else { './config.toml' }
return path_env
}
return './config.toml'
} }

View File

@ -1,7 +1,7 @@
module main module main
import vweb import vweb
import sqlite import db.sqlite
import time import time
import os import os
@ -43,7 +43,7 @@ fn main() {
// } // }
mut host := '::' mut host := '::'
if app_config.host != '' { if app_config.host.len != 0 {
host = app_config.host host = app_config.host
} }

View File

@ -48,7 +48,7 @@ pub fn (mut app App) score_submit() vweb.Result {
return app.json(Status{400, 'Bad JSON object'}) return app.json(Status{400, 'Bad JSON object'})
} }
if body.player.trim_space() == '' { if body.player.trim_space().len == 0 {
app.set_status(400, '') app.set_status(400, '')
return app.json(Status{400, 'Name cannot be empty'}) 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] ['/api/v1/score/list'; options]
pub fn (mut app App) handle_score_list_cors() vweb.Result { pub fn (mut app App) handle_score_list_options() vweb.Result {
return app.handle_cors() return app.handle_options()
} }
['/api/v1/score/submit'; options] ['/api/v1/score/submit'; options]
pub fn (mut app App) handle_score_submit_cors() vweb.Result { pub fn (mut app App) handle_score_submit_options() vweb.Result {
return app.handle_cors() 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.set_status(204, '')
app.add_cors_headers() app.add_cors_headers()
return app.ok('') return app.ok('')

2
v.mod
View File

@ -1,7 +1,7 @@
Module { Module {
name: 'highscore-server' name: 'highscore-server'
description: 'A generic highscore server for a game' description: 'A generic highscore server for a game'
version: '1.0.0' version: '1.1'
license: 'AGPLv3-only' license: 'AGPLv3-only'
repo_url: 'https://git.snrd.eu/sunred/highscore-server' repo_url: 'https://git.snrd.eu/sunred/highscore-server'
vcs: 'git' vcs: 'git'