Skip to content

Instantly share code, notes, and snippets.

Rus Hart rhart

Block or report user

Report or block rhart

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View IsbnDbCommands.groovy
public Promise<String> getBookRequest(final String isbn) {
def uri = "${config.host}/api/v2/json/${config.apikey}/book/$isbn".toURI()
httpClient
.get(uri)
.map { ReceivedResponse resp ->
if (resp.body.text.contains("Daily request limit exceeded")) {
throw new RuntimeException("ISBNDB daily request limit exceeded.")
}
resp.body.text
View ratpack-proxy.groovy
import io.netty.bootstrap.Bootstrap
import io.netty.buffer.ByteBuf
import io.netty.channel.ChannelFuture
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.ChannelInitializer
import io.netty.channel.ChannelPipeline
import io.netty.channel.SimpleChannelInboundHandler
import io.netty.channel.socket.SocketChannel
import io.netty.handler.codec.http.DefaultFullHttpResponse
import io.netty.handler.codec.http.HttpResponseStatus
@rhart
rhart / Ratpack.groovy
Created Dec 20, 2014
Ratpack HTTP Proxy
View Ratpack.groovy
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import ratpack.handling.Context
import ratpack.handling.Handler
import ratpack.http.client.HttpClient
import ratpack.http.client.StreamedResponse
import ratpack.http.MutableHeaders
import ratpack.http.client.RequestSpec
import static ratpack.groovy.Groovy.ratpack
@rhart
rhart / gist:b4316b43b8323e32cf9e
Created Aug 2, 2014
Ratpack publishing to websocket
View gist:b4316b43b8323e32cf9e
public class MetricsWebsocketBroadcastHandler implements Handler {
@Override
public void handle(final Context context) throws Exception {
final MetricsPublisher publisher = context.get(MetricsPublisher.class);
websocket(context, new AutoCloseWebSocketHandler<AutoCloseable>() {
@Override
public AutoCloseable onOpen(final WebSocket webSocket) throws Exception {
MetricsWebsocketSubscriber subscriber = new MetricsWebsocketSubscriber(webSocket);
View WorldCup2014.adoc

The World Cup Graph

Initial Data Setup

@rhart
rhart / ratpack.groovy
Last active Apr 5, 2016
Ratpack SOAP web service
View ratpack.groovy
import static org.ratpackframework.groovy.RatpackScript.ratpack
import static org.ratpackframework.groovy.Template.groovyTemplate
ratpack {
handlers {
prefix('say-hello-service') {
soapAction('"Hello"') {
def soapRequest = new XmlSlurper().parseText(request.text)
def yourFirstName = soapRequest.Body.HelloRequest.FirstName
You can’t perform that action at this time.