Skip to content

Commit

Permalink
Fix bug in settings API
Browse files Browse the repository at this point in the history
  • Loading branch information
qtc-de committed Sep 8, 2023
1 parent 9c29a72 commit 6646147
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ struct App {
}

struct RpvWebSettings {
symbol_path string
symbol_file string
mut:
symbol_path string
}

pub fn (app App) before_request()
Expand Down
13 changes: 8 additions & 5 deletions src/settings-api.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ pub fn (mut app App) get_settings() vweb.Result
['/api/settings'; post]
pub fn (mut app App) set_settings() vweb.Result
{
settings := json2.decode[RpvWebSettings](app.req.data) or
if json_body := json2.raw_decode(app.req.data)
{
return app.json(g_settings)
}
json_map := json_body.as_map()

g_symbol_resolver.symbol_path = settings.symbol_path
g_settings = settings
if symbol_path := json_map['symbol_path'].str()
{
g_symbol_resolver.symbol_path = symbol_path
g_settings.symbol_path = symbol_path
}
}

return app.json(g_settings)
}

0 comments on commit 6646147

Please sign in to comment.