This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EnableWebSecurity | |
public class SecurityConfig extends WebSecurityConfigurerAdapter { | |
@Bean | |
public HttpSessionStrategy httpSessionStrategy() { | |
return new HeaderHttpSessionStrategy(); | |
} | |
@Autowired | |
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/api") | |
public class Controller { | |
@RequestMapping(value = "/resource", method = RequestMethod.GET) | |
public Map<String, String> getResource() { | |
Map<String, String> resource = new HashMap<String, String>(); | |
resource.put("resource", "here is some resource"); | |
return resource; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void configure(HttpSecurity http) throws Exception { | |
http | |
.authorizeRequests() | |
.antMatchers(HttpMethod.OPTIONS, "/api/resource").permitAll() | |
.anyRequest().authenticated() | |
.and() | |
.requestCache() | |
.requestCache(new NullRequestCache()) | |
.and() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LogInterceptor extends TurboFilter { | |
@Override | |
public FilterReply decide(Marker marker, Logger logger, Level level, String s, Object[] objects, Throwable throwable) { | |
boolean logChanged = false; | |
if (objects != null) { | |
for (int i = 0; i < objects.length; i++) { | |
if (objects[i] instanceof String) { | |
String str = (String) objects[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration> | |
<turboFilter class="filters.LogInterceptor" /> | |
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
<encoder> | |
<pattern> | |
%-4relative [%thread] %-5level %logger - %msg%n | |
</pattern> | |
</encoder> | |
</appender> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EnableWebSecurity | |
public class SecurityConfig extends WebSecurityConfigurerAdapter { | |
@Bean | |
public HttpSessionStrategy httpSessionStrategy() { | |
return new HeaderHttpSessionStrategy(); | |
} | |
@Autowired | |
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"timestamp":1503137711145, | |
"info":{ | |
"method":"GET", | |
"path":"/actuator", | |
"headers":{ | |
"request":{ | |
"host":"localhost:8080", | |
"connection":"keep-alive", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class RequestTraceFilter extends WebRequestTraceFilter { | |
private final String[] excludedEndpoints = new String[]{"/css/**", "/js/**", "/trace"}; | |
RequestTraceFilter(TraceRepository repository, TraceProperties properties) { | |
super(repository, properties); | |
} | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Repository | |
public class CustomTraceRepository extends InMemoryTraceRepository { | |
private static final Logger log = LoggerFactory.getLogger(CustomTraceRepository.class); | |
public CustomTraceRepository() { | |
super.setCapacity(200); | |
} | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.experimental.TimeoutCancellationException | |
import kotlinx.coroutines.experimental.async | |
import kotlinx.coroutines.experimental.delay | |
import kotlinx.coroutines.experimental.runBlocking | |
import kotlinx.coroutines.experimental.withTimeout | |
import kotlin.system.measureTimeMillis | |
// lightweight replacement for spring retry | |
suspend fun <T> retry(maxRetryCount: Int = 5, timeout: Long = 3000, block: suspend (retryCount: Int) -> T): T { | |
for (i in 1..maxRetryCount) { |
OlderNewer