Skip to content

Route forwarding server proxy - #119

Merged
fmazmz merged 19 commits into
mainfrom
feat/111-route-forwarding-proxy
Feb 23, 2026
Merged

Route forwarding server proxy#119
fmazmz merged 19 commits into
mainfrom
feat/111-route-forwarding-proxy

Conversation

@fmazmz

@fmazmz fmazmz commented Feb 22, 2026

Copy link
Copy Markdown
Member

Whats new?

  • ProxyRoute.java holds a mapping of a basePath and its respective target upstream URL.
    The mappings are added in application-properties.yml and loaded through the ConfigLoader, stored as ProxyRoute objects.

  • ProxyPlugin.java, for each ProxyRoute object, we initialize a new ProxyPlugin.
    The plugin handles the following:
    -Logs the incoming request from the client.
    -Constructs a new HttpRequest and copies the headers, body, and method from the initial Client request.
    -Proxies the new request through an HttpClient to the target server URL.
    -Handles and returns the upstream server response and returns it back to the client.

  • HttpStatus.java (ENUM) holds the most common Http Status Codes and their respective String description. Allows us to easily translate the statusCode from the upstream server response and dynamically relay an http status text to the client.

  • Integration tests and Unit tests added for ProxyPlugin to test most basic scenarios, both with a real HttpClient and a mock.

  • One proxy route added to the server config as following:

server:
  port: 8080
  root-dir: static
  proxy:
    routes:
      - base-route: /api/test
        upstream-url: https://jsonplaceholder.typicode.com

How to run an example request to test the proxy?

  • Run the application locally
  • Visit localhost:8080/api/test/{route} - with any of the routes documented below or at https://jsonplaceholder.typicode.com/

The request should be proxied to the external server.

Resources

JSONPlaceholder comes with a set of 6 common resources:

   
/posts 100 posts
/comments 500 comments
/albums 100 albums
/photos 5000 photos
/todos 200 todos
/users 10 users

closes #111
@coderabbitai ignore

@fmazmz
fmazmz marked this pull request as ready for review February 23, 2026 15:07
@fmazmz
fmazmz requested review from addee1, bamsemats and kappsegla and removed request for addee1 and bamsemats February 23, 2026 15:07
kristinaxm
kristinaxm previously approved these changes Feb 23, 2026

@kristinaxm kristinaxm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

Comment thread src/main/java/org/juv25d/proxy/ProxyPlugin.java
@fmazmz
fmazmz merged commit 1167331 into main Feb 23, 2026
2 checks passed
@fmazmz
fmazmz deleted the feat/111-route-forwarding-proxy branch February 23, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add proxy functionality for base‑route forwarding

3 participants