Skip to content

Commit

Permalink
Merge pull request #342 from shapenaji/master
Browse files Browse the repository at this point in the history
Combines PR 340 and PR 341 and fixes email for CLA
  • Loading branch information
schloerke committed Nov 30, 2018
2 parents f47fe91 + a69749a commit 4f2e73d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions R/plumber.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,17 @@ plumber <- R6Class(
filters <- list()
}

# Initialize
private$serializer <- serializer_json()
private$errorHandler <- defaultErrorHandler()
private$notFoundHandler <- default404Handler

# Add in the initial filters
for (fn in names(filters)){
fil <- PlumberFilter$new(fn, filters[[fn]], private$envir, private$serializer, NULL)
private$filts <- c(private$filts, fil)
}

private$errorHandler <- defaultErrorHandler()
private$notFoundHandler <- default404Handler

if (!is.null(file)){
private$lines <- readUTF8(file)
private$parsed <- parseUTF8(file)
Expand Down Expand Up @@ -271,7 +273,7 @@ plumber <- R6Class(
super$registerHook(stage, handler)
},

handle = function(methods, path, handler, preempt, serializer, endpoint){
handle = function(methods, path, handler, preempt, serializer, endpoint, ...){
epdef <- !missing(methods) || !missing(path) || !missing(handler) || !missing(serializer)
if (!missing(endpoint) && epdef){
stop("You must provide either the components for an endpoint (handler and serializer) OR provide the endpoint yourself. You cannot do both.")
Expand All @@ -282,7 +284,7 @@ plumber <- R6Class(
serializer <- private$serializer
}

endpoint <- PlumberEndpoint$new(methods, path, handler, private$envir, serializer)
endpoint <- PlumberEndpoint$new(methods, path, handler, private$envir, serializer, ...)
}
private$addEndpointInternal(endpoint, preempt)
},
Expand Down Expand Up @@ -630,7 +632,7 @@ plumber <- R6Class(
paths
}
), private = list(
serializer = serializer_json(), # The default serializer for the router
serializer = NULL, # The default serializer for the router

ends = list(), # List of endpoints indexed by their pre-empted filter.
filts = NULL, # Array of filters
Expand Down

0 comments on commit 4f2e73d

Please sign in to comment.