# Middleware for Custom RPC

**URL:** https://forum.heroiclabs.com/t/middleware-for-custom-rpc/5138
**Category:** Runtime Framework
**Tags:** golang
**Created:** [April 4, 2024, 4:50am UTC](https://forum.heroiclabs.com/t/middleware-for-custom-rpc/5138 "2024-04-04T04:50:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vladislav-chunikhin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/vladislav-chunikhin/32/2133_2.png) [@vladislav-chunikhin](https://forum.heroiclabs.com/u/vladislav-chunikhin)
#### Post date: [April 4, 2024, 4:50am UTC](https://forum.heroiclabs.com/t/middleware-for-custom-rpc/5138/1 "2024-04-04T04:50:42Z")

</div>

Hi there! Is it possible to implement middleware for logging request/response or customizing error handling? Can I use RegisterBeforeRt and RegisterAfterRt for that? I’ve tried to implement it on my own, but it wasn’t successful. Is there someone who can resolve this task? Currently, I use a helper to customize my errors, but I have to add it for every RPC method.

---

<div class="post-metadata">

### Author: ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)
#### Post date: [April 4, 2024, 11:25am UTC](https://forum.heroiclabs.com/t/middleware-for-custom-rpc/5138/2 "2024-04-04T11:25:20Z")

</div>

Hello @vladislav-chunikhin, as you mention this would have to be done via `RegisterBefore/AfterRt`, can you elaborate on what is it that you would like to log, how you’d like to customize the errors, and what is it that you weren’t able to achieve with the hooks?
