@@ -266,8 +266,6 @@ void ngx_link_func_init_cycle(ngx_link_func_cycle_t* cycle) {
266
266
is_service_on=1;
267
267
}
268
268
269
-
270
-
271
269
void my_app_simple_get_greeting(ngx_link_func_ctx_t * ctx) {
272
270
ngx_link_func_log_info(ctx, "Calling back and log from my_app_simple_get");
273
271
@@ -276,41 +274,56 @@ void my_app_simple_get_greeting(ngx_link_func_ctx_t *ctx) {
276
274
200,
277
275
"200 OK",
278
276
"text/plain",
279
- "greeting from ngx_link_func testing"
277
+ "greeting from ngx_link_func testing",
278
+ sizeof("greeting from ngx_link_func testing")-1
280
279
);
281
280
}
282
281
283
282
void my_app_simple_get_args(ngx_link_func_ctx_t * ctx) {
284
283
ngx_link_func_log_info(ctx, "Calling back and log from my_app_simple_get_args");
285
284
286
- ngx_link_func_write_resp(
287
- ctx,
288
- 200,
289
- "200 OK",
290
- "text/plain",
291
- ctx->req_args
292
- );
285
+ if(ctx->req_args) {
286
+ ngx_link_func_write_resp(
287
+ ctx,
288
+ 200,
289
+ "200 OK",
290
+ "text/plain",
291
+ ctx->req_args,
292
+ strlen(ctx->req_args)
293
+ );
294
+ } else {
295
+ ngx_link_func_write_resp(
296
+ ctx,
297
+ 204,
298
+ "",
299
+ "text/plain",
300
+ NULL,
301
+ 0
302
+ );
303
+ }
293
304
}
294
305
295
306
void my_app_simple_get_token_args(ngx_link_func_ctx_t * ctx) {
296
307
ngx_link_func_log_info(ctx, "Calling back and log from my_app_simple_get_token_args");
297
308
298
- char * tokenArgs = ngx_link_func_get_query_param(ctx, "token");
309
+ char * tokenArgs = (char*) ngx_link_func_get_query_param(ctx, "token");
299
310
if (! tokenArgs) {
300
311
ngx_link_func_write_resp(
301
312
ctx,
302
313
401,
303
314
"401 unauthorized",
304
315
"text/plain",
305
- "Token Not Found"
316
+ "Token Not Found",
317
+ sizeof("Token Not Found")-1
306
318
);
307
319
} else {
308
320
ngx_link_func_write_resp(
309
321
ctx,
310
322
401,
311
323
"401 unauthorized",
312
324
"text/plain",
313
- tokenArgs
325
+ tokenArgs,
326
+ strlen(tokenArgs)
314
327
);
315
328
}
316
329
}
@@ -323,8 +336,8 @@ void my_app_simple_post(ngx_link_func_ctx_t *ctx) {
323
336
202,
324
337
"202 Accepted and Processing",
325
338
"text/plain",
326
- ctx->req_body ,
327
- ctx->req_body
339
+ NULL ,
340
+ 0
328
341
);
329
342
}
330
343
@@ -333,7 +346,7 @@ void my_app_simple_post(ngx_link_func_ctx_t *ctx) {
333
346
void my_app_simple_get_no_resp(ngx_link_func_ctx_t * ctx) {
334
347
ngx_link_func_log_info(ctx, "Calling back and log from my_app_simple_get_no_resp");
335
348
336
-
349
+ // return 404
337
350
}
338
351
339
352
void ngx_link_func_exit_cycle(ngx_link_func_cycle_t* cyc) {
0 commit comments