/*
 * (C) Copyright 2018 Boni Garcia (http://bonigarcia.github.io/)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package io.github.bonigarcia.wdm;

import static io.github.bonigarcia.wdm.WebDriverManager.chromedriver;
import static io.github.bonigarcia.wdm.WebDriverManager.edgedriver;
import static io.github.bonigarcia.wdm.WebDriverManager.firefoxdriver;
import static io.github.bonigarcia.wdm.WebDriverManager.iedriver;
import static io.github.bonigarcia.wdm.WebDriverManager.operadriver;
import static io.github.bonigarcia.wdm.WebDriverManager.phantomjs;
import static java.lang.invoke.MethodHandles.lookup;
import static org.apache.commons.io.FileUtils.openInputStream;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.File;

import org.slf4j.Logger;

import io.javalin.Handler;
import io.javalin.Javalin;

/**
 * WebDriverManager server.
 *
 * @author Boni Garcia (boni.gg@gmail.com)
 * @since 3.0.0
 */
public class Server {

    final Logger log = getLogger(lookup().lookupClass());

    public Server(int port) {
        Javalin app = Javalin.create().start(port);
        Handler handler = ctx -> {

            String requestMethod = ctx.method();
            String requestPath = ctx.path();
            log.info("Server request: {} {}", requestMethod, requestPath);

            WebDriverManager driverManager = null;
            switch (requestPath.substring(1)) {
            case "chromedriver":
                driverManager = chromedriver();
                break;
            case "firefoxdriver":
                driverManager = firefoxdriver();
                break;
            case "edgedriver":
                driverManager = edgedriver();
                break;
            case "iedriver":
                driverManager = iedriver();
                break;
            case "operadriver":
                driverManager = operadriver();
                break;
            case "phantomjs":
                driverManager = phantomjs();
                break;
            }

            driverManager.setup();
            File binary = new File(driverManager.getBinaryPath());
            String binaryVersion = driverManager.getDownloadedVersion();
            String binaryName = binary.getName();
            String binaryLength = String.valueOf(binary.length());

            ctx.res.setHeader("Content-Disposition",
                    "attachment; filename=\"" + binaryName + "\"");
            ctx.res.setHeader("Content-Length", binaryLength);
            ctx.res.setHeader("Content-Type", "application/octet-stream");

            ctx.result(openInputStream(binary));

            log.info("Server response: {} {} ({} bytes)", binaryName,
                    binaryVersion, binaryLength);
        };

        app.get("/chromedriver", handler);
        app.get("/firefoxdriver", handler);
        app.get("/edgedriver", handler);
        app.get("/iedriver", handler);
        app.get("/operadriver", handler);
        app.get("/phantomjs", handler);

        log.info("WebDriverManager server listening on port {}", port);
    }

}
@@ -2524,19 +2524,145 @@
         
-%7D%0A%0A
+default:%0A                log.warn(%22Unknown option %7B%7D%22, requestPath);%0A            %7D%0A%0A            if (driverManager != null) %7B%0A    
         
@@ -2684,24 +2684,28 @@
 er.setup();%0A
+    
             
@@ -2763,32 +2763,36 @@
 ));%0A            
+ 
+   
 String binaryVer
@@ -2840,32 +2840,36 @@
 ();%0A            
+    
 String binaryNam
@@ -2886,24 +2886,28 @@
 .getName();%0A
+    
             
@@ -2966,32 +2966,36 @@
 );%0A%0A            
+    
 ctx.res.setHeade
@@ -3009,90 +3009,48 @@
 ent-
-Disposition%22,%0A                    %22attachment; filename=%5C%22%22 + binaryName + %22%5C%22%22);%0A
+Type%22, %22application/octet-stream%22);%0A    
     
@@ -3112,32 +3112,36 @@
 h);%0A            
+    
 ctx.res.setHeade
@@ -3155,45 +3155,99 @@
 ent-
-Type%22, %22application/octet-stream
+Disposition%22,%0A                        %22attachment; filename=%5C%22%22 + binaryName + %22%5C%22
 %22);%0A%0A
+    
     
@@ -3296,32 +3296,36 @@
 );%0A%0A            
+ 
+   
 log.info(%22Server
@@ -3386,16 +3386,20 @@
         
+    
 binaryVe
@@ -3412,32 +3412,46 @@
  binaryLength);%0A
+            %7D%0A
         %7D;%0A%0A    
@@ -3775,9 +3775,124 @@
 %0A    %7D%0A%0A
+    public static void main(String%5B%5D args) %7B%0A        new Server(WebDriverManager.config().getServerPort());%0A    %7D%0A%0A
 %7D

Add a default case to switch in server logic