Skip to content

Instantly share code, notes, and snippets.

View xring's full-sized avatar
🎯
Focusing

xring

🎯
Focusing
View GitHub Profile
case class Person1(name: String, age: Int, other: Option[String])
case class Person2(name: String, age: Int, other: String)
import play.api.libs.functional.syntax._
import play.api.libs.json._
implicit val person1Format = (
(JsPath \ "name").format[String] and
(JsPath \ "age").format[Int] and
(JsPath \ "other").formatNullable[String].inmap[Option[String]](x => Some(x.getOrElse("default")), y => y)
@xring
xring / java-8-maven-idea.md
Created August 2, 2017 02:13
idea lambda expressions are not supported in -source 1.5

When using lambda in a Maven based project in IntelliJ IDEA, got

idea lambda expressions are not supported in -source 1.5

solved by add this in pom file:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
 maven-compiler-plugin

MicroService Proxy Gateway Solutions

Kong, Traefik, Caddy, Linkerd, Fabio, Vulcand, and Netflix Zuul seem to be the most common in microservice proxy/gateway solutions. Kubernetes Ingress is often a simple Ngnix, which is difficult to separate the popularity from other things.

Github Star Trend:

Github Star History for Kong vs traefik vs fabio vs caddy vs Zuul

This is just a picture of this link from March 2, 2019

Originally, I had included some other solution

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
name: api
namespace: x
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- api.xring.info
@RestController
@Slf4j
public class AuthController {
@GetMapping("/")
public void auth(HttpServletRequest request, HttpServletResponse response) {
Map<String, String> headers = new HashMap<>();
Enumeration headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: inf-auth-gateway-rest
spec:
workloadLabels:
app: istio-ingressgateway
filters:
- listenerMatch:
portNumber: 443
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: inf-auth-gateway-rest
labels:
app: inf-auth-gateway-rest
spec:
replicas: 1
selector:
matchLabels:
<dependencies>
<dependency>
<groupId>io.envoyproxy.controlplane</groupId>
<artifactId>api</artifactId>
<version>0.1.15</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.20.0</version>
import com.google.rpc.Status;
import io.envoyproxy.envoy.service.auth.v2.AuthorizationGrpc;
import io.envoyproxy.envoy.service.auth.v2.CheckRequest;
import io.envoyproxy.envoy.service.auth.v2.CheckResponse;
import io.envoyproxy.envoy.service.auth.v2.DeniedHttpResponse;
import io.envoyproxy.envoy.type.HttpStatus;
import io.envoyproxy.envoy.type.StatusCode;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.stub.StreamObserver;
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: inf-auth-gateway-grpc
labels:
app: inf-auth-gateway-gprc
spec:
replicas: 1
selector:
matchLabels: