文件上传,下载异步
This commit is contained in:
parent
4796f51458
commit
9c28894d5a
@ -6,10 +6,11 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.cloud.gateway.route.RouteLocator;
|
||||
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
import org.yaml.snakeyaml.util.UriEncoder;
|
||||
|
||||
@EnableConfigurationProperties
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(scanBasePackages = {"ink.wgink"})
|
||||
public class WgGatewayApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -0,0 +1,40 @@
|
||||
package ink.wgink.gateway.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: WebFluxConfig
|
||||
* @Description:
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/14 2:42 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class WebFluxFilterConfig implements WebFilter {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) {
|
||||
serverWebExchange.getRequest().getHeaders().forEach((k, list) -> {
|
||||
System.out.println(k);
|
||||
list.forEach(System.out::println);
|
||||
});
|
||||
|
||||
return webFilterChain.filter(serverWebExchange);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Flux.just("你好1", "你好2").subscribe(c -> {
|
||||
System.out.println(c);
|
||||
});
|
||||
|
||||
Mono.just("1").subscribe(System.out::println);
|
||||
}
|
||||
}
|
@ -10,5 +10,5 @@ spring:
|
||||
|
||||
logging:
|
||||
level:
|
||||
org: debug
|
||||
org.springframework: debug
|
||||
ink.wgink: debug
|
73
src/test/java/ink/wgink/gateway/LambdaTest.java
Normal file
73
src/test/java/ink/wgink/gateway/LambdaTest.java
Normal file
@ -0,0 +1,73 @@
|
||||
package ink.wgink.gateway;
|
||||
|
||||
import java.util.function.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: LambdaTest
|
||||
* @Description:
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/16 10:05 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class LambdaTest {
|
||||
|
||||
public static class Dog {
|
||||
private String name = "单身狗";
|
||||
private int food = 10;
|
||||
|
||||
public Dog() {
|
||||
}
|
||||
|
||||
public Dog(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static void bark(Dog dog) {
|
||||
System.out.println(dog + "叫了");
|
||||
}
|
||||
|
||||
public int eat(int num) {
|
||||
System.out.println(this.name + "吃了" + num + "斤");
|
||||
this.food -= num;
|
||||
return this.food;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Dog dog = new Dog();
|
||||
|
||||
// 静态方法
|
||||
Consumer<Dog> consume = Dog::bark;
|
||||
consume.accept(dog);
|
||||
|
||||
// 通过实例得到方法的引用
|
||||
Function<Integer, Integer> function = dog::eat;
|
||||
System.out.println("还剩下" + function.apply(2) + "斤");
|
||||
|
||||
UnaryOperator<Integer> unaryOperator = dog::eat;
|
||||
IntUnaryOperator intUnaryOperator = dog::eat;
|
||||
|
||||
System.out.println("还剩下" + intUnaryOperator.applyAsInt(2) + "斤");
|
||||
|
||||
// 使用类名得到非静态方法的引用,输入两个值,输出一个值
|
||||
BiFunction<Dog, Integer, Integer> biFunction = Dog::eat;
|
||||
System.out.println("还剩下" + biFunction.apply(dog, 1) + "斤");
|
||||
|
||||
// 得到没有构造参数的引用
|
||||
Supplier<Dog> supplierDog = Dog::new;
|
||||
System.out.println("还剩下" + supplierDog.get().eat(1) + "斤");
|
||||
|
||||
// 得到一个参数的
|
||||
Function<String, Dog> functionDog = Dog::new;
|
||||
System.out.println("还剩下" + functionDog.apply("李四").eat(1) + "斤");
|
||||
}
|
||||
|
||||
}
|
38
src/test/java/ink/wgink/gateway/LambdaTest2.java
Normal file
38
src/test/java/ink/wgink/gateway/LambdaTest2.java
Normal file
@ -0,0 +1,38 @@
|
||||
package ink.wgink.gateway;
|
||||
|
||||
import java.util.function.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: LambdaTest
|
||||
* @Description:
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/16 10:05 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class LambdaTest2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Function<Integer, Integer> result = x -> x;
|
||||
System.out.println(result.apply(1));
|
||||
|
||||
Function<Integer, Function<Double, Double>> result2 = x -> y -> x + y;
|
||||
System.out.println(result2.apply(2).apply(2.2));
|
||||
|
||||
Function<Integer, Function<Integer, Function<Integer, Integer>>> result3 = x -> y -> z -> x + y + z;
|
||||
System.out.println("结果:"+ result3.apply(1).apply(2).apply(3));
|
||||
int[] nums = {1, 2, 3};
|
||||
Function f = result3;
|
||||
for(int i = 0; i < nums.length; i++) {
|
||||
Object n = f.apply(nums[i]);
|
||||
if(n instanceof Function) {
|
||||
f = (Function) n;
|
||||
} else {
|
||||
System.out.println("循环结果:" + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user