• / company
    • about us
      • / about us

        The partner of choice for data & product engineering to drive business growth & deliver an impact within your organization
    • product engineering
      • / product engineering
        We specialize in Software Product Engineering, transforming your concepts into impactful products.
    • technology
      • / technology
        250+ specialists skilled in software, BI, integration, offering end-to-end services from research to ongoing maintenance.
    • methodology
      • / methodology
        We specialize in software product engineering, transforming your concepts into impactful products.
    • careers
      • / careers
        Our team needs one more awesome person, like you. Let’s grow together! Why not give it a try?
    • do good
      • / do good
        We’re a team devoted to making the world better with small acts. We get involved and always stand for kindness.
    • events
      • / events
        LLMs in Action: Transforming How We Work, Communicate, and Innovate
    • blog
      • / blog
        Why Every Developer Should Care About AI Plugins, And What You Might Be Missing
        mindit chats with Andreea Moldovan: “At mindit.io people really put effort into making it happen.”
    • contact us
      • / contact us
        We would love to hear from you! We have offices and teams in Romania and Switzerland. How can we make your business thrive?
  • / get in touch

Spring Boot – Custom endpoints using RegEx

What do you do when REST conventions are seemingly impossible to follow?
Brief

Let’s say we have a user management system that we designed using the REST API guidelines.

The URL on which we access a user would be: /users/{userId}

Say your business logic is based on the userId.

For users with a userId that starts with 1 you return a type of response or do some logic
For users with a userId that starts with 2 you return a different type of response or do a different logic

You don’t want change the URL as you would break the REST API conventions, so the client requests should still be sent to /users/{userId}.
Implementation

This is where Spring comes to rescue.

RequestMapping and all its implementations GetMapping, PostMapping, etc. support Regular Expressions so you have even more precision when defining your Controllers.

You can find more details on the official Spring MVC Documentation website.

For our case we can write something like this:

Let’s test it with some requests in Postman.

Distribute:

/turn your vision into reality

The best way to start a long-term collaboration is with a Pilot project. Let’s talk.