Skip to content

Instantly share code, notes, and snippets.

plugins {
id 'java'
}
group 'de.predic8'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
@predic8
predic8 / books.py
Last active August 24, 2018 09:19
Python REST API Boilderplate with falcon
# pip3 install falcon
# pip3 install gunicorn
# gunicorn books:app
#
# Windows:
#
# $ pip install waitress
# $ waitress-serve --port=8000 things:app
import falcon
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<spring:camelContext>
@predic8
predic8 / main.txt
Created February 7, 2018 14:49
WebFlux main with Netty
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(ReactiveWebApplication.class, args);
HttpHandler handler = WebHttpHandlerBuilder.applicationContext(ctx).build();
ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
HttpServer.create("localhost", 8080).newHandler(adapter).block();
}
@predic8
predic8 / WebConfig.java
Created February 7, 2018 14:45
WebFlux Config
package de.predic8.reactiveweb;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" media="screen"/>
</head>
<body>
<div class="container">
<h1>The Jokes</h1>
INSERT INTO joke (joke) VALUES ('Jon Skeet does not have performance bottlenecks. He just makes the universe wait its turn.')
INSERT INTO joke (joke) VALUES ('Users do not mark Jon Skeets answers as accepted. The universe accepts them out of a sense of truth and justice.')
INSERT INTO joke (joke) VALUES ('Jon Skeet coded his last project entirely in Microsoft Paint, just for the challenge.')
@predic8
predic8 / books.json
Last active September 17, 2017 19:39
{
"e746eec0-9bde-11e7-b0a1-194366ce7859" : {
"id": "e746eec0-9bde-11e7-b0a1-194366ce7859",
"title" : "Moby-Dick",
"author" : "Herman Melville",
"year" : 1851
},
"f1817e50-9bde-11e7-b0a1-194366ce7859" : {
"id": "f1817e50-9bde-11e7-b0a1-194366ce7859",
"title" : "Vingt mille lieues sous les mers",
'use strict';
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({
host: 'localhost',
port: 8000
});
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="file:in" />