GoogleCloudPlatform / functions-framework-java

FaaS (Function as a service) framework for writing portable Java functions
Apache License 2.0
133 stars 63 forks source link

Consider supporting JEP 445 #209

Open josephlewis42 opened 1 year ago

josephlewis42 commented 1 year ago

JEP 445 (Preview in JDK 21) introduces unnamed classes and instance main methods. This could be a boon to writing functions if done right changing our result from this:

package com.example;

import com.google.cloud.functions.HttpFunction;
import com.google.cloud.functions.HttpRequest;
import com.google.cloud.functions.HttpResponse;

public class HelloWorld implements HttpFunction {
  @Override
  public void service(HttpRequest request, HttpResponse response)
      throws Exception {
    response.getWriter().write("Hello, World\n");
  }
}

To something like this:

import com.google.cloud.functions.FuncFramework;

void main() {
    FuncFramework.http((req, res) -> response.getWriter().write("Hello, World\n"));
}