Created
June 21, 2020 06:52
Revisions
-
vavasthi created this gist
Jun 21, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ package in.springframework.blog.tutorials.endpoints; import in.springframework.blog.tutorials.entities.OauthClientDetails; import in.springframework.blog.tutorials.services.ClientService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import java.util.Optional; @RestController @RequestMapping("/oauth/client") public class ClientEndpoint { @Autowired private ClientService clientService; @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public Iterable<OauthClientDetails> getClients() { return clientService.findAll(); } @RequestMapping(value = "/{clientId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public Optional<OauthClientDetails> getClient(@PathVariable("clientId") String clientId) { return clientService.findById(clientId); } @RequestMapping(value = "/{clientId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) public Optional<OauthClientDetails> getClient(@PathVariable("clientId") String clientId, @RequestBody OauthClientDetails clientDetails) { return clientService.update(clientId, clientDetails); } }