Skip to content

Instantly share code, notes, and snippets.

@vepo
Last active October 15, 2023 00:23
Show Gist options
  • Save vepo/01fb0a608ef123bfa956f0f328163616 to your computer and use it in GitHub Desktop.
Save vepo/01fb0a608ef123bfa956f0f328163616 to your computer and use it in GitHub Desktop.
@Path("/user") // JAX-RS
@ApplicationScoped // CDI
public class UserEndpoint {
@GET
@Produces(MediaType.APPLICATION_JSON)
public UserListResponse listUsers() {
// List os usuários
}
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public NewUserResponse newUser(NewUserRequest request) {
// Crie novo usuário
}
@DELETE
@Path("{id}")
public void deleteUser(@PathParam("id") Long id) {
// Remova o usuário
}
}
@RestController
public class UserEndpoint {
@GetMapping("/user")
public UserListResponse listUsers() {
// List os usuários
}
@PostMapping("/user")
public NewUserResponse newUser(@RequestBody NewUserRequest request) {
// Crie novo usuário
}
@DeleteMapping("/user/{id}")
public void deleteUser(@PathVariable Long id) {
// Remova o usuário
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment