Browse Source

Add default redirect

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.2-alpha
Pekka Helenius 4 years ago
parent
commit
1459fb754b
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      bookstore/src/main/java/com/fjordtek/bookstore/web/BookRestController.java

+ 21
- 0
bookstore/src/main/java/com/fjordtek/bookstore/web/BookRestController.java View File

@ -6,10 +6,12 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import com.fjordtek.bookstore.model.Book;
@ -26,6 +28,9 @@ public class BookRestController {
private CategoryRepository categoryRepository;
*/
// TODO Use single variable reference for all controllers
private static final String bookListPageView = "booklist";
private HttpServerLogger httpServerLogger = new HttpServerLogger();
@RequestMapping(
@ -57,4 +62,20 @@ public class BookRestController {
return bookRepository.findById(bookId);
}
//////////////////////////////
// REDIRECTS
@RequestMapping(
value = { "*" }
)
@ResponseStatus(HttpStatus.FOUND)
public void redirectToDefaultWebForm(
HttpServletRequest requestData,
HttpServletResponse responseData
) {
httpServerLogger.log(requestData, responseData);
responseData.setHeader("Location", "/" + bookListPageView);
responseData.setStatus(302);
}
}

Loading…
Cancel
Save