Marc Kupietz | 5bbc9db | 2019-08-30 16:30:45 +0200 | [diff] [blame] | 1 | #' @import jsonlite |
| 2 | #' @import curl |
| 3 | |
Marc Kupietz | 5bbc9db | 2019-08-30 16:30:45 +0200 | [diff] [blame] | 4 | defaultKorAPUrl <- "https://korap.ids-mannheim.de/" |
| 5 | |
Marc Kupietz | 632cbd4 | 2019-09-06 16:04:51 +0200 | [diff] [blame] | 6 | #' \code{KorAPQuery} initiates a connect to some KorAP server. |
| 7 | #' @param KorAPUrl instead of providing the query and vc string parameters, you can also simply copy a KorAP query URL from your browser and use it here (and in \code{KorAPConnection}) to provide all necessary information for the query. |
| 8 | #' @return object that contains all necessary connection information and can be used on \code{\link{KorAPQuery}} |
| 9 | #' @export |
| 10 | KorAPConnection <- function(KorAPUrl=defaultKorAPUrl, apiVersion='v1.0', apiUrl = NA) { |
| 11 | m <-regexpr("https?://[^?]+", KorAPUrl, perl = TRUE) |
| 12 | KorAPUrl <- regmatches(KorAPUrl, m) |
| 13 | if (!endsWith(KorAPUrl, '/')) { |
| 14 | KorAPUrl <- paste0(KorAPUrl, "/") |
| 15 | } |
| 16 | if (is.na(apiUrl)) { |
| 17 | apiUrl = paste0(KorAPUrl, 'api/', apiVersion, '/') |
| 18 | } |
Marc Kupietz | 5bbc9db | 2019-08-30 16:30:45 +0200 | [diff] [blame] | 19 | con <- data.frame(apiUrl, KorAPUrl, apiVersion) |
| 20 | return(con) |
| 21 | } |