Skip to content

Commit

Permalink
Merge pull request #18 from grafana/java-redirect
Browse files Browse the repository at this point in the history
Java example: Redirect from root path
  • Loading branch information
zeitlinger authored Feb 12, 2024
2 parents 44c45d2 + d9172ba commit 39f4894
Show file tree
Hide file tree
Showing 2 changed files with 14 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
13 changes: 13 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,24 @@
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 {

/**
* Redirect to {@link RollController}
*/
@GetMapping("/")
public void redirect(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 39f4894

Please sign in to comment.