This file contains 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
using Microsoft.Owin.Hosting; | |
using Owin; | |
using System; | |
using System.Web.Http; | |
using Topshelf; | |
namespace SelfHostDemo | |
{ | |
public class Program | |
{ |
This file contains 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
using Microsoft.Owin; | |
using System.IO; | |
using System.Threading.Tasks; | |
namespace uShip.Microservice.WebApi.Framework | |
{ | |
/// <summary> | |
/// Buffers the request stream to allow for reading multiple times. | |
/// The Katana (OWIN implementation) implementation of request streams | |
/// is different than that of IIS. |
This file contains 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
using Microsoft.Owin; | |
using System.Runtime.Remoting.Messaging; | |
using System.Threading.Tasks; | |
namespace uShip.Microservice.WebApi.Framework | |
{ | |
/// <summary> | |
/// Sets the current <see cref="IOwinContext"/> for later access via <see cref="OwinCallContext.Current"/>. | |
/// Inspiration: https://github.com/neuecc/OwinRequestScopeContext | |
/// </summary> |
This file contains 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 play.api.libs.iteratee.Enumerator; | |
import play.api.mvc.ResponseHeader; | |
import play.api.mvc.Result; | |
import scala.Enumeration; | |
import scala.Tuple2; | |
import scala.collection.JavaConversions; | |
import scala.collection.mutable.Buffer; | |
import java.util.ArrayList; | |
import java.util.List; |
This file contains 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 play.GlobalSettings; | |
import play.api.mvc.EssentialFilter; | |
public class Global extends GlobalSettings { | |
@Override | |
public <T extends EssentialFilter> Class<T>[] filters() { | |
return new Class[] {HelloFilter.class}; | |
} |
This file contains 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 play.api.mvc.RequestHeader; | |
import play.api.mvc.Result; | |
public class HelloFilter extends JavaFilter { | |
@Override | |
public Result Apply(Result currentResult, RequestHeader requestHeader) { | |
if (requestHeader.headers().get("X-Filter").isDefined()) { | |
ResultAdapter resultAdapter = new ResultAdapter(currentResult); | |
return resultAdapter.WithHeader("X-Hello", "World!"); |
This file contains 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 play.api.mvc.*; | |
import scala.Function1; | |
import scala.concurrent.Future; | |
import scala.runtime.AbstractFunction1; | |
public abstract class JavaFilter implements Filter { | |
@Override | |
public Future<Result> apply(Function1<RequestHeader, Future<Result>> nextFilter, RequestHeader requestHeader) { | |
return nextFilter |