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 {
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' }
}

View File

@ -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
}

View File

@ -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('')

2
v.mod
View File

@ -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'