Skip to content

Commit

Permalink
Java example: Redirect from root path
Browse files Browse the repository at this point in the history
  • Loading branch information
fstab committed Feb 11, 2024
1 parent 44c45d2 commit a4c413a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

@RestController
public class RollController {

private static final Logger logger = LoggerFactory.getLogger(RollController.class);

@GetMapping("/rolldice")
Expand Down
10 changes: 10 additions & 0 deletions examples/java/src/main/java/com/grafana/example/SpringBootApp.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package com.grafana.example;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class SpringBootApp {

@GetMapping("/")
public void redirec(HttpServletResponse httpServletResponse) {
httpServletResponse.setHeader("Location", "/rolldice");
httpServletResponse.setStatus(302);
}

public static void main(String[] args) {
SpringApplication.run(SpringBootApp.class, args);
}
Expand Down

0 comments on commit a4c413a

Please sign in to comment.