Skip to content

Instantly share code, notes, and snippets.

@livioribeiro
livioribeiro / ErrorHandlerControllerAdvice.kt
Created March 1, 2019 14:01
Handling controller exceptions on Spring Boot
/*
* Based on: https://docs.spring.io/spring-boot/docs/2.1.3.RELEASE/reference/htmlsingle/#boot-features-error-handling
*/
package com.myorg.myproject.controller.advice
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
@livioribeiro
livioribeiro / OidcConfig.java
Last active June 29, 2020 02:46
Spring Boot 2.1+ OAuth2 Client Keycloak
@Configuration
public class OidcConfig {
@Bean
public GrantedAuthoritiesMapper authoritiesMapper() {
return new GrantedAuthoritiesMapper() {
@Override
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) {
return authorities;
}
};
@livioribeiro
livioribeiro / nginx.conf
Created January 19, 2018 10:07
Simplest proxy to docker swarm services
# based on https://serverfault.com/questions/291703/dynamic-backends-with-haproxy/292581#292581
server {
listen 80;
server_name *.localtest.me;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
resolver 127.0.0.11;