mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
feat: support fumadocs
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ import java.util.Base64;
|
||||
@CrossOrigin("*")
|
||||
public class ClassNameParseController {
|
||||
|
||||
@PostMapping("/className")
|
||||
@PostMapping("/api/className")
|
||||
public String className(@RequestBody String classBase64) {
|
||||
return ClassNameReader.getClassName(new ClassReader(Base64.getDecoder().decode(classBase64)));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.*;
|
||||
* @since 2024/12/13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/config")
|
||||
@RequestMapping("/api/config")
|
||||
@CrossOrigin("*")
|
||||
public class ConfigController {
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import java.util.Base64;
|
||||
* @since 2024/12/18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/memshell/generate")
|
||||
@RequestMapping("/api/memshell/generate")
|
||||
@CrossOrigin("*")
|
||||
public class MemShellGeneratorController {
|
||||
@PostMapping
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
* @since 2025/8/10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/probe/generate")
|
||||
@RequestMapping("/api/probe/generate")
|
||||
@CrossOrigin("*")
|
||||
public class ProbeShellGeneratorController {
|
||||
@PostMapping
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Map;
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
@RequestMapping("/version")
|
||||
@RequestMapping("/api/version")
|
||||
public class VersionController {
|
||||
|
||||
@Value("${spring.application.version}")
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
package com.reajason.javaweb.boot.controller;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
@@ -11,6 +21,51 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
public class ViewController {
|
||||
@GetMapping("/")
|
||||
public String index(){
|
||||
return "index";
|
||||
return "redirect:/ui";
|
||||
}
|
||||
|
||||
@GetMapping({"/api/search", "/api/search.data"})
|
||||
@ResponseBody
|
||||
public String handleSearch(HttpServletRequest request, HttpServletResponse response) {
|
||||
String fullPath = request.getRequestURI();
|
||||
String relativePath = fullPath.substring(1);
|
||||
return renderFileData(relativePath, response);
|
||||
}
|
||||
|
||||
@GetMapping({"/ui/docs/*.data", "/ui/*.data"})
|
||||
@ResponseBody
|
||||
public String handleDataFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
String fullPath = request.getRequestURI();
|
||||
String relativePath = fullPath.substring(4);
|
||||
return renderFileData(relativePath, response);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/ui/**")
|
||||
public String handleHtmlView(HttpServletRequest request) {
|
||||
String fullPath = request.getRequestURI();
|
||||
String viewPath = fullPath.substring(3);
|
||||
return viewPath + "/index";
|
||||
}
|
||||
|
||||
private String renderFileData(String relativePath, HttpServletResponse response) {
|
||||
try {
|
||||
String templatePath = "templates/" + relativePath;
|
||||
ClassPathResource resource = new ClassPathResource(templatePath);
|
||||
if (!resource.exists()) {
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
return "File not found: " + relativePath;
|
||||
}
|
||||
response.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
InputStreamReader reader = new InputStreamReader(
|
||||
resource.getInputStream(),
|
||||
StandardCharsets.UTF_8
|
||||
);
|
||||
return FileCopyUtils.copyToString(reader);
|
||||
} catch (IOException e) {
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
return "Error reading file: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
spring:
|
||||
application:
|
||||
name: boot
|
||||
version: ${version}
|
||||
version: ${version}
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
Reference in New Issue
Block a user