api design - How to get client IP address in R Plumber -


i've checked github repo , doc still couldn't figure out how client ip in plumber.

here implementation tried, want add ip addresses requests log file,

#' @post /v1/rl rl_v1 <- function(a, b, c){   request='rl'   start_time <- as.numeric(as.posixct(sys.time()))   log_record <- paste(null, sys.time(), request, "requested", null, null,                    sep=",")   cat(paste(log_record, "\n", sep=""), file=log_file_name, append=t)    lhs <- data.frame(a=unlist(a),                 b=unlist(b),                 c=unlist(c))    pairs <- custom_function(lhs, rhs, m_w = 0.98,                                 ext_blk_field=c(12), international=t,                                 fasterwcoblock=t, preprocesseddata2=t)   input_records=nrow(lhs)   matches=nrow(pairs)   query_time <- as.numeric(as.posixct(sys.time())) - start_time   status <- data.frame(query_time=query_time,                     request=request,                     type='post',                    api_version=api_version_v1)    log_record <- paste(null, sys.time(), request, "responded",                    round(matches/input_records*100, 2),                    paste0(matches, '/', input_records, ' in ', query_time),                    sep=",")   cat(paste(log_record, "\n", sep=""), file=log_file_name, append=t)    return(list(data=pairs, status=status)) } 

any highly appreciated.

to close out question, i'll restate comment:

since plumber uses httpuv, it's possible can reach req$remote_addr property of request handle.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -