Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michael Black
OpenXG-RAN
Commits
7a7b2ff4
Commit
7a7b2ff4
authored
Apr 15, 2022
by
frtabu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt command response structure
parent
32e49924
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
common/utils/websrv/websrv.c
common/utils/websrv/websrv.c
+18
-11
No files found.
common/utils/websrv/websrv.c
View file @
7a7b2ff4
...
...
@@ -67,6 +67,22 @@ void websrv_printjson(char * label, json_t *jsonobj){
char
*
jstr
=
json_dumps
(
jsonobj
,
0
);
LOG_I
(
UTIL
,
"[websrv] %s:%s
\n
"
,
label
,
(
jstr
==
NULL
)
?
"??
\n
"
:
jstr
);
}
/*-----------------------------------*/
/* build a json body in a response */
void
websrv_jbody
(
struct
_u_response
*
response
,
json_t
*
jbody
)
{
websrv_printjson
(
(
char
*
)
__FUNCTION__
,
jbody
);
int
us
=
ulfius_add_header_to_response
(
response
,
"content-type"
,
"application/json"
);
if
(
us
!=
U_OK
){
ulfius_set_string_body_response
(
response
,
500
,
"Internal server error (ulfius_add_header_to_response)"
);
LOG_E
(
UTIL
,
"[websrv] cannot set response header type ulfius error %d
\n
"
,
us
);
}
us
=
ulfius_set_json_body_response
(
response
,
200
,
jbody
);
if
(
us
!=
U_OK
){
ulfius_set_string_body_response
(
response
,
500
,
"Internal server error (ulfius_set_json_body_response)"
);
LOG_E
(
UTIL
,
"[websrv] cannot set body response ulfius error %d
\n
"
,
us
);
}
return
;
}
/*----------------------------------------------------------------*/
/* format a json string array in a response body */
...
...
@@ -79,17 +95,8 @@ int websrv_string_response(char *astring, struct _u_response * response, int htt
json_array_append_new
(
jstr
,
jline
);
aline
=
strtok_r
(
NULL
,
"
\n
"
,
&
tokctx
);
}
websrv_printjson
(
(
char
*
)
__FUNCTION__
,
jstr
);
int
us
=
ulfius_add_header_to_response
(
response
,
"content-type"
,
"application/json"
);
if
(
us
!=
U_OK
){
ulfius_set_string_body_response
(
response
,
500
,
"Internal server error (ulfius_add_header_to_response)"
);
LOG_E
(
UTIL
,
"[websrv] cannot set response header type ulfius error %d
\n
"
,
us
);
}
us
=
ulfius_set_json_body_response
(
response
,
200
,
jstr
);
if
(
us
!=
U_OK
){
ulfius_set_string_body_response
(
response
,
500
,
"Internal server error (ulfius_set_json_body_response)"
);
LOG_E
(
UTIL
,
"[websrv] cannot set body response ulfius error %d
\n
"
,
us
);
}
json_t
*
jbody
=
json_pack
(
"{s:o}"
,
"display"
,
jstr
);
websrv_jbody
(
response
,
jbody
);
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment