0

Need a filter which can show non responsive url with an error code

    #* Return LDA of all sites
    #* @param a Enter your Website
    #* @param b:[chr] Enter URLs
    #* @param v The focused keyword
    #* pr_set_error(pr, fun)
    function(req, res){
      if (req$b== FALSE){
        res$status <- 500 # Unauthorized
        return(list(error="Unresponsive URL"))
      } else {
        plumber::forward()
      }
    }
    #* @post  /LDA
    
    function(a,b,v) {

#calculation}

please help me!

  • Could elaborate your question please? Plumber will return a 404 status on "unresponsive" url. Is that what you want to change? – Bruno Tremblay Oct 16 '20 at 18:17
  • yes..is this a right way or anything you want to add?? basically I want to check user gave valid responsive url or not?before do any calculation – Sabyasachi Datta Oct 17 '20 at 04:56

1 Answers1

0

I'm wildly guessing here

#* Return LDA of all sites
#* @param a Enter your Website
#* @param b:[chr] Enter URLs
#* @param v The focused keyword
#* @post  /LDA
function(a,b,v) {
  #calculation
}

#* @filter unresponsive_url
function(req, res){
  if (any(req$args$b == FALSE)) {
    res$status <- 500 # Unauthorized
    return(list(error="Unresponsive URL"))
  } else {
    plumber::forward()
  }
}
Bruno Tremblay
  • 756
  • 4
  • 9