spring-cloud / spring-cloud/spring-cloud-config

Allowing to use query parameters as further filter to select the right Environment from EnvironmentRepository

Open
#1,124 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting for votes
Dominant language
Java
Stars
2k
Forks
1.3k
Avg merge
2d 59m
Merged PRs (30d)
16

Description

Problem

I have to access to config server besides springboot applications also from SPA (AngularJS).

I've used the REST api provided out-of-box from config server but the triad application/profile/label seem to me is not enough to express the complexity coming out from my requirements.

Requirements

Acquire configuration from the same app installed in different devices where configuration is different depending from deviceId and location

The natural solution that I've imaged was to call api like application/profile/label?device=x&location=y but I haven't found a simple way to achieve that.

Solution

The solution that I've figured out are:

  1. try to use profile and/or label like Json object (eg. application/profile/{label:'',device:'',location:''})
  2. publish a custom endpoint from my config server
  3. Add a filter and use stuff like ThreadLocal

Proposal

During this analysis I've figured out that if the Request object will be passed to findOne(String application, String profile, String label); method of EnvironmentRepository this allowing to use query parameters as further filter to select the right Environment

The proposal is to extends the EnvironmentRepository interface as show below

public interface EnvironmentRepository {

	Environment findOne(String application, String profile, String label);

	default Environment findOne(Request request, String application, String profile, String label) {
                 return findOne(application, profile, label);
         }

}

and update ResourceController accordly with new interface

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the EnvironmentRepository interface and ResourceController, then inspect the existing findOne implementations and how requests reach the controller. Determine how query parameters should be passed without breaking the current method, and consider the existing comment discussion before defining done as repository implementations being able to use the request data through the REST endpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend, cloud
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.