mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: add json_pretty method (#12745)
This commit is contained in:
@@ -244,6 +244,13 @@ pub fn (mut ctx Context) json<T>(j T) Result {
|
||||
return Result{}
|
||||
}
|
||||
|
||||
// Response HTTP_OK with a pretty-printed JSON result
|
||||
pub fn (mut ctx Context) json_pretty<T>(j T) Result {
|
||||
json_s := json.encode_pretty(j)
|
||||
ctx.send_response_to_client('application/json', json_s)
|
||||
return Result{}
|
||||
}
|
||||
|
||||
// Response HTTP_OK with file as payload
|
||||
pub fn (mut ctx Context) file(f_path string) Result {
|
||||
ext := os.file_ext(f_path)
|
||||
|
||||
Reference in New Issue
Block a user