Files
2026-06-10 14:46:58 +02:00

47 lines
1003 B
R
Executable File

# 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 <- 'l0vabe3n2bv3r2kfmpawakavr64lsc'
#* @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/<cheptel>
#' @param cheptel:number
#' @serializer unboxedJSON
maj_ecow_chep <- function(cheptel) {
maj_ecow_by_cheptel(cheptel)
}
#' @get /ecow/tech/<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()
}