GithubHelp home page GithubHelp logo

ehsaniara / spring-cloud-pcf-sample Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 73 KB

Spring Cloud example for Tanzu Application Service (TAZ)

License: Apache License 2.0

Java 100.00%
pcf spring-boot spring-cloud tanzu-application-service

spring-cloud-pcf-sample's Introduction

Spring Cloud for Tanzu Application Service (TAS)

First we need to create manifest.yml for every project which go into TAS

For this example we are using java-buildpack.

---
applications:
  - name: gw 
    buildpack: https://github.com/cloudfoundry/java-buildpack.git#v4.48.2
    instances: 1
    memory: 512M
    env:
      SPRING_PROFILES_ACTIVE: cloud
      JAVA_OPTS: -Xms256m -Xmx256m -Xss64m
      JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+}}'
      JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}'

For More details, please visit VMware Tanzu Application Service.

URL base routing

In project gw

@Bean
public RouteLocator MyRoute(RouteLocatorBuilder builder) {
    return builder//
            .routes()//
            .route("svc1", r -> r.path("/svc1/**")
                    //
                    .filters(f -> f.stripPrefix(1))
                    //
                    .uri("lb://svc1"))//
            .route("svc2", r -> r.path("/svc2/**")
                    //
                    .filters(f -> f.filter(authFilter).stripPrefix(1))
                    //
                    .uri("lb://svc2"))//
            .build();
}

Service 1

🚦All traffics from the given URL pattern will be forwarded into SVC1 microservice

curl -i http://localhost:8080/svc1

Service 2

🚦All traffics from the given URL pattern will be forwarded into SVC2 microservice.

In addition request should carry the Authorization header otherwise return πŸ›‘401 Error

🚧 You can impediment desire auth logic in AuthFilter.java from gw project

curl -i -H "Authorization: Bearer jayWTea..." http://localhost:8080/svc2

spring-cloud-pcf-sample's People

Contributors

ehsaniara avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.