Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 3.75 KB

File metadata and controls

48 lines (33 loc) · 3.75 KB

RESTHeart Example Plugins

This collection showcases various RESTHeart plugins, each serving a specific purpose. Below is a brief overview of each plugin:

Configuration files

Java Plugins

  • Greeter Service: Implements two basic Java REST Web services returning Text and JSON payloads. Demonstrates usage of ByteArrayService and JsonService interfaces.
  • CSV Interceptor: Illustrates how to snoop and modify requests with Interceptors.
  • User Signup: Implement user signup processes. It's a quite complex example that utilizes interceptors, services, JSON schema validation, and security permissions.
  • MongoDB serverStatus Service: Offers access to MongoDB's serverStatus system call and demonstrates how to inject the MongoClient in a plugin.
  • Slack Notifier: An asynchronous interceptor that posts messages to a Slack channel when a document is created in a specified collection.
  • Random String Service: Provides random strings. Showcases deployment of services with external dependencies.
  • Protocol Buffer Contacts: Interceptors adjusting request and response formats to and from MongoService for Protocol Buffer payloads.
  • Freemarker HTML page: Generates HTML Web pages using Apache Freemarker.
  • Custom Logging Field: Details adding custom fields to logs via MDC Context.
  • Form Header: A Service with a bespoke Request to manage Form POST requests.
  • Instance name: This interceptor adds a custom X-Restheart-Instance header to all responses processed by any service in RESTHeart. It serves as a practical demonstration of using the WildcardInterceptor interface and illustrates how to inject the Configuration object into a plugin.
  • X-Headers-to-qparams: offers a convenient way to convert specific request headers into query parameters, showing how to dynamically modify the request before it reaches the designated handling Service.
  • X-Powered-By Remover: Response interceptors that remove the X-Powered-By: restheart.org header from service and proxied resource responses, showing how to dynamically modify the response after it has been generated by the designated handling Service.

Kotlin Plugins

JavaScript Plugins

  • JavaScript Plugins: A compilation of example JavaScript plugins.
  • Node Plugin: A JavaScript plugin for RESTHeart, running on GraalVM's Node.js implementation.
  • Credit Card Hider: A JavaScript Interceptor that obfuscates credit card numbers in responses. Demonstrates response transformation in existing Services.

Requirements to Build and Run the Examples

To work with these examples, the following are required:

  1. Java 25: Install it using sdkman:

    $ sdk install java 25-tem
  2. Docker: Necessary for running RESTHeart and MongoDB.

  3. HTTPie: A command-line HTTP client for testing, available at httpie.io/cli.

Note: The examples use Maven, but it's accessible through the included Maven wrapper (mvnw), so a separate installation is not required.