Experimental Azure function adapter for HTTP trigger

This commit is contained in:
Soby Chacko
2017-11-26 20:50:09 -05:00
committed by Dave Syer
parent 73098244e3
commit 308e4d5514
12 changed files with 679 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
/*
* Copyright 2017 the original author or authors.
*
* 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 example;
import java.util.function.Function;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
class FooConfig {
@Bean
public Function<Foo, Bar> uppercase() {
return value -> new Bar(value.getValue().toUpperCase());
}
public static void main(String[] args) throws Exception {
SpringApplication.run(FooConfig.class, args);
}
}
class Foo {
private String value;
Foo() {
}
public String lowercase() {
return value.toLowerCase();
}
public Foo(String value) {
this.value = value;
}
public String uppercase() {
return value.toUpperCase();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
class Bar {
private String value;
Bar() {
}
public Bar(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2017 the original author or authors.
*
* 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 example;
import com.microsoft.azure.serverless.functions.ExecutionContext;
import org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHandler;
/**
* @author Soby Chacko
*/
public class FooHandler extends AzureSpringBootRequestHandler {
@SuppressWarnings("unchecked")
public Bar handleRequest(Foo foo, ExecutionContext context) {
context.getLogger().info("Invoking entry point method");
return (Bar)super.handleRequest(foo,context);
}
}