Skip to content

Instantly share code, notes, and snippets.

@zachpendleton
Created July 1, 2021 10:05
Show Gist options
  • Save zachpendleton/3467395ad666dc152fc11ce4124b6f95 to your computer and use it in GitHub Desktop.
Save zachpendleton/3467395ad666dc152fc11ce4124b6f95 to your computer and use it in GitHub Desktop.
management:
endpoints:
web:
exposure:
include:
- course
- health
- beans
server:
port: 3000 # run on a port that is not exposed on the firewall or security group
address: 127.0.0.1 # restrict to requests from localhost
package com.example.demo.actuator;
import com.example.demo.model.Course;
import com.example.demo.repository.CoursesRepository;
import java.util.List;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.stereotype.Component;
@Endpoint(id = "course")
@Component
public class CreateCourseActuator {
private CoursesRepository repository;
public CreateCourseActuator(CoursesRepository repository) {
this.repository = repository;
}
@ReadOperation
public List<Course> readCourses() {
return repository.findAll();
}
@WriteOperation
public void createCourse(String name) {
repository.create(new Course(name));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment