title: What is the best practice for RestController?
body: <p>Code convention says no logic in the controllers. All should be handled in the service layer. My question is especially about returning ResponseEntity.</p>
  
  <p>Should it be handled in RestController or in Service layer?</p>
  
  <p>I tried both ways. I think RestController is the suitable place to return ResponseEntity. Because we are using mappings in the RestController.</p>
  
  <p>On the other hand, we know the controllers should not include any logic.</p>
  
  <pre><code>@GetMapping("/{id}")
  public ResponseEntity&lt;Employee&gt; getEmployee(@PathVariable Long id) {
      return ResponseEntity.ok(employeeService.findEmployeeById(id);
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>@GetMapping("/{id}")
  public ResponseEntity&lt;Employee&gt; getEmployee(@PathVariable Long id) {
      return employeeService.findEmployeeById(id);
  }
  </code></pre>
  
  <p>ControllerAdvice for exception handling is my another concern. Which way is the best to use?</p>
  
  <p>Thanks for your advance.</p>