Skip to content

Instantly share code, notes, and snippets.

@simon04
simon04 / Application.java
Last active September 29, 2023 08:06
Lightweight REST API using Jersey on embedded Jetty server
package root;
import root.resources.HelloResource;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
public class Application {
@thesamet
thesamet / ReverseProxy.scala
Created November 5, 2014 23:36
Reverse-proxy in Play!
def reverseProxy = Action.async(parse.raw) {
request: Request[RawBuffer] =>
// Create the request to the upstream server:
val proxyRequest =
WS.url("http://localhost:8887" + request.path)
.withFollowRedirects(false)
.withMethod(request.method)
.withVirtualHost("localhost:9000")
.withHeaders(flattenMultiMap(request.headers.toMap): _*)
.withQueryString(request.queryString.mapValues(_.head).toSeq: _*)