Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade versions and used Handler interface #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion template/java11-vert-x/entrypoint/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mainClassName = 'App'

dependencies {
// Vert.x project
compile 'io.vertx:vertx-web:3.5.4'
compile 'io.vertx:vertx-web:3.8.5'

// Use JUnit test framework
testCompile 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import io.vertx.ext.web.Router;
import io.vertx.ext.web.handler.StaticHandler;
import io.vertx.ext.web.handler.BodyHandler;

import com.openfaas.function.Handler;

import java.util.Optional;

public class App {
Expand All @@ -18,13 +21,15 @@ public static void main(String[] args) throws Exception {

if (Boolean.parseBoolean(Optional.ofNullable(System.getenv("FRONTAPP")).orElse("false"))) {
// serve static assets, see /resources/webroot directory
router.route("/*").handler(StaticHandler.create());
router.route().handler(StaticHandler.create());
} else {
BodyHandler handler = new com.openfaas.function.Handler();
router.route().handler(handler);
// enable body parsing (i.e.: POST, multipart, etc...)
router.route().handler(BodyHandler.create());
// allow usage of any verb for the function
router.route().handler(new Handler());
}

server.requestHandler(router::accept).listen(httpPort, result -> {
server.requestHandler(router).listen(httpPort, result -> {
if(result.succeeded()) {
System.out.println("Listening on port " + httpPort);
} else {
Expand Down
2 changes: 1 addition & 1 deletion template/java11-vert-x/function/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {

dependencies {
// Vert.x project
compile 'io.vertx:vertx-web:3.5.4'
compile 'io.vertx:vertx-web:3.8.5'

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.openfaas.function;

import io.vertx.core.http.HttpServerResponse;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BodyHandler;
import io.vertx.core.json.JsonObject;

public class Handler implements BodyHandler {
public class Handler implements io.vertx.core.Handler<RoutingContext> {

@Override
public void handle(RoutingContext routingContext) {
Expand All @@ -17,24 +15,4 @@ public void handle(RoutingContext routingContext) {
.encodePrettily()
);
}

@Override
public BodyHandler setBodyLimit(long bodyLimit) {
return null;
}

@Override
public BodyHandler setUploadsDirectory(String uploadsDirectory) {
return null;
}

@Override
public BodyHandler setMergeFormAttributes(boolean mergeFormAttributes) {
return null;
}

@Override
public BodyHandler setDeleteUploadedFilesOnEnd(boolean deleteUploadedFilesOnEnd) {
return null;
}
}