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
// Original Copyright 2012 Google, Inc. All rights reserved. | |
// | |
// Use of this source code is governed by a BSD-style license | |
// that can be found in the LICENSE file in the root of the source | |
// tree. | |
// Modification Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
// SPDX-License-Identifier: BSD-3-Clause | |
package main |
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 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 |
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 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 |
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 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 |
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 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); |
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 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 |