Minor tweaks & changes for latest vlang version
This commit is contained in:
parent
24a9cdc8cf
commit
a011f54361
4 changed files with 11 additions and 14 deletions
|
@ -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' }
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
12
src/web.v
12
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('')
|
||||
|
|
2
v.mod
2
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'
|
||||
|
|
Loading…
Reference in a new issue