Skip to content

Instantly share code, notes, and snippets.

View azare's full-sized avatar

Erik Azar azare

View GitHub Profile

Keybase proof

I hereby claim:

  • I am azare on github.
  • I am panic88 (https://keybase.io/panic88) on keybase.
  • I have a public key ASDIj00r803VJn5YC7HVE2j0yRHMIyHufB1k-Ocb7hHmjQo

To claim this, I am signing this object:

@azare
azare / Sieve.swift
Created January 27, 2016 04:27
Sieve of Eratosthenes in Swift
//
// Sieve.swift
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Erik J. Azar
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@azare
azare / ServiceContext.java
Created July 24, 2015 15:40
Service context class used for ThreadLocal storage
public class ServiceContext {
private static final ThreadLocal<ServiceContext> instance = new ThreadLocal<ServiceContext>();
public static ServiceContext get() {
if (instance.get() == null) {
instance.set(new ServiceContext());
}
return instance.get();
}
@azare
azare / ResponseHeaderInterceptor.java
Created July 24, 2015 15:38
Outbound interceptor that adds a new header with the services original response status code
public class ResponseHeaderInterceptor extends AbstractPhaseInterceptor<Message> {
private static final String ORIGINAL_HTTP_STATUS_CODE = "X-Original-Http-Status-Code";
public ResponseHeaderInterceptor() {
super(Phase.MARSHAL);
}
@SuppressWarnings("unchecked")
@Override
@azare
azare / RequestHeaderInterceptor.java
Created July 24, 2015 15:33
Incoming interceptor that reads the HTTP request headers
public class RequestHeaderInterceptor extends AbstractPhaseInterceptor<Message> {
private final static String HEADER_STATUS_CODE_OVERRIDE_KEY = "X-HTTP-Status-Code-Override";
public AuthenticationInterceptor() {
super(Phase.READ);
}
@SuppressWarnings("unchecked")
@Override
@azare
azare / OutboundHttpStatusCodeInterceptor.java
Created July 24, 2015 15:29
Outbound Interceptor to rewrite the response status code
public class OutboundHttpStatusCodeInterceptor extends AbstractPhaseInterceptor<Message> {
public OutboundHttpStatusCodeInterceptor() {
super(Phase.SEND);
}
@Override
public void handleMessage(Message message) {
if (ServiceContext.get().isHttpStatusCodeValueOverridden()) {