2020-09-10 20:19:19 +03:00
|
|
|
package com.baeldung.optionalpathvars;
|
2019-11-16 01:07:27 +02:00
|
|
|
|
2020-09-10 20:19:19 +03:00
|
|
|
import static com.baeldung.optionalpathvars.Article.DEFAULT_ARTICLE;
|
2019-11-16 01:07:27 +02:00
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping(value = "/seperateMethods")
|
|
|
|
|
public class ArticleViewerWithTwoSeparateMethodsController {
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/article/{id}")
|
|
|
|
|
public Article getArticle(@PathVariable(name = "id") Integer articleId) {
|
|
|
|
|
|
|
|
|
|
return new Article(articleId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/article")
|
|
|
|
|
public Article getDefaultArticle() {
|
|
|
|
|
|
|
|
|
|
return DEFAULT_ARTICLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|