# Point d'entrée du routeur Plumber source(here::here('R/project/ecow_calculations.R')) source(here::here('R/project/Untitled.R')) source(here::here('R/project/postprocessing.R')) API_KEY <- 'mon_super_token_long_et_secret' #* @filter authenticate authenticate <- function(req, res) { api_key_req <- req$args$RAPIKEY api_key_ref <- API_KEY if (is.null(api_key_req) || api_key_req != api_key_ref) { res$status <- 401 return(list(error = "Unauthorized")) } forward() } #' Fonction pour tester appel de l'API #' @get /admin/test #' @serializer json test <- function() { ma_fonction() } #' @get /ecow/cheptel/ #' @param cheptel:number #' @serializer unboxedJSON maj_ecow_chep <- function(cheptel) { maj_ecow_by_cheptel(cheptel) } #' @get /ecow/tech/ #' @param tech:number #' @serializer unboxedJSON maj_ecow_tech <- function(tech) { maj_ecow_by_tech(tech) } #' @get /ecow/all #' @serializer unboxedJSON maj_ecow_all <- function() { maj_ecow_for_all() }