feat: add reverse proxy config

This commit is contained in:
guqing
2022-06-09 18:43:57 +08:00
parent 2691a0394d
commit 32c93b5de1
11 changed files with 131 additions and 2 deletions

View File

@@ -33,6 +33,9 @@ dependencies {
compileOnly 'org.springframework.boot:spring-boot-starter-webflux'
annotationProcessor 'io.github.guqing:pluggable-suite:0.0.1-SNAPSHOT'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

View File

@@ -1,4 +1,4 @@
package io.github.guqing.apples;
package io.github.guqing.template;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

View File

@@ -0,0 +1,27 @@
package io.github.guqing.template.post;
import java.time.LocalDateTime;
import lombok.Data;
/**
* @author guqing
* @since 2.0.0
*/
@Data
public class Post {
private String id;
private String userId;
private String topicId;
private String raw;
private String cooked;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
private LocalDateTime deletedAt;
private String replyToPostNumber;
private Integer replyCount;
private Integer quoteCount;
private Integer likeCount;
private Integer offTopicCount;
private Integer postType;
private Integer sortOrder;
}

View File

@@ -0,0 +1,26 @@
package io.github.guqing.template.post;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
/**
* @author guqing
* @since 2.0.0
*/
@RestController
@RequestMapping("/apis/template.guqing.github.com/v1alpha1/posts")
public class PostController {
private final PostService postService;
public PostController(PostService postService) {
this.postService = postService;
}
@GetMapping
public Flux<Post> list() {
return postService.list();
}
}

View File

@@ -0,0 +1,43 @@
package io.github.guqing.template.post;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
/**
* @author guqing
* @since 2.0.0
*/
@Component
public class PostRepository {
private final Map<String, Post> postMap = new ConcurrentHashMap<>();
public PostRepository() {
Post post = new Post();
post.setId(UUID.randomUUID().toString());
post.setRaw("静态方法适合生成简单的序列,当需要复杂的逻辑时,则应该使用 generate() 或 create() 方法。\n");
post.setCooked(post.getRaw());
post.setPostType(1);
post.setCreatedAt(LocalDateTime.now());
post.setLikeCount(1);
post.setReplyCount(0);
post.setOffTopicCount(0);
post.setUserId(UUID.randomUUID().toString());
post.setTopicId(UUID.randomUUID().toString());
post.setSortOrder(1);
postMap.put(post.getId(), post);
}
public Flux<Post> findAll() {
return Flux.create(sink -> {
for (Post value : postMap.values()) {
sink.next(value);
}
sink.complete();
});
}
}

View File

@@ -0,0 +1,20 @@
package io.github.guqing.template.post;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
/**
* @author guqing
* @since 2.0.0
*/
@Service
public class PostService {
@Autowired
private PostRepository postRepository;
public Flux<Post> list() {
return postRepository.findAll();
}
}

View File

@@ -0,0 +1,8 @@
apiVersion: v1
kind: ReverseProxy
metadata:
name: reverse-proxy-template
rules:
- path: /assets/io.github.guqing.template/**
file:
directory: static

View File

@@ -14,4 +14,4 @@ spec:
# 'displayName' explains what the plugin does in only a few words
displayName: "测试插件"
description: "这是一个用来测试的插件"
license: MIT
license: MIT1

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

View File

@@ -0,0 +1 @@
花径不曾缘客扫,蓬门今始为君开

View File

@@ -0,0 +1 @@
<div>测试中文乱码 hello apples</div>