Simple service to receive callbacks. Useful for when testing APIs locally that send callbacks
- Java 17 or above
- Download latest sources and run:
./gradlew build run
Once up and running you can set the callback url of the API you are testing to the callback endpoint of callback-logger
-
http://localhost:7070/callback-logger/api/callback
. Both POST
and PUT
methods are supported for the callback
endpoint along with multiple content types. You can send a callback manually using the following curl
request:
curl -X POST --location "http://localhost:7070/callback-logger/api/callback" \
-H "Content-Type: application/json" \
-d "{\"hello\": \"world\"}"
or
curl -X PUT --location "http://localhost:7070/callback-logger/api/callback" \
-H "Content-Type: application/xml" \
-d "<hello>world</hello>"
If you need to send callbacks to different callback endpoints than the default callback-logger
endpoint then you can
define custom callbacks. Custom callbacks are defined in the application.conf
file and are defined as a list of put
or post
URIs. For example:
callback-logger {
custom-callbacks {
post = ["/api/custom1", "/api/custom2"]
put = ["/api/custom1"]
}
}
Any duplicate URIs will be ignored and all custom URIs need to start with a /
. You can then send callbacks to the
custom endpoints using the following curl
request:
curl -X PUT --location "http://localhost:7070/api/custom1" \
-H "Content-Type: application/xml" \
-d "<hello>world</hello>"
By default, callback-logger returns a 200
response code for all callbacks. If you need to return a different response
code then you can define the response code in the application.conf
file. For example:
callback-logger {
custom-callback-response-code = 201
callback-response-payload = ""
custom-callbacks {
post = ["/api/custom1", "/api/custom2"]
put = ["/api/custom1"]
}
}
The application will fail to start if the response code is not a valid http response code.
By default, callback-logger returns an empty string as the response payload for all callbacks. If you need to return a different response
payload then you can change that in the application.conf
file. For example:
callback-logger {
custom-callback-response-code = 200
callback-response-payload = "{\"status\": \"OK\", \"message\": \"Callback received\"}"
custom-callbacks {
post = ["/api/custom1", "/api/custom2"]
put = ["/api/custom1"]
}
}
callback-logger
provides a simple web interface to allow you to see the callbacks you have received. You can access
the web interface by pointing your browser to http://localhost:7070/callback-logger
:
./gradlew test
👤 Lee Turner
- Mastodon: @leeturner
- Twitter: @leeturner
Feel free to ping me 😉
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Open an issue first to discuss what you would like to change.
- Fork the Project
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a pull request
Please make sure to update tests as appropriate.
Give a ⭐️ if this project helped you!
- Setup releases using jReleaser
Copyright © 2023 - Lee Turner
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This README was generated by readgen ❤