Mise en place projet R
This commit is contained in:
Executable
+47
@@ -0,0 +1,47 @@
|
||||
# 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/<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()
|
||||
}
|
||||
Reference in New Issue
Block a user