Skip to content

Commit

Permalink
Step 3 – Set up your web server
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr.kazmierczak committed Dec 2, 2016
1 parent 5a72529 commit 6d7ce69
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
25 changes: 25 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
baseName = 'gs-spring-boot'
version = '0.1.0'
}

repositories {
jcenter()
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile('org.springframework.boot:spring-boot-starter-web') {
exclude module: "spring-boot-starter-tomcat"
}
compile('org.springframework.boot:spring-boot-starter-jetty')
compile('org.springframework.boot:spring-boot-starter-actuator')

compile 'io.ably:ably-java:0.8.+'
}
13 changes: 13 additions & 0 deletions src/main/java/io/ably/tutorial/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.ably.tutorial;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class Application {

public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
}
}
9 changes: 9 additions & 0 deletions src/main/java/io/ably/tutorial/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import io.ably.lib.rest.AblyRest;
import io.ably.lib.types.AblyException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Example {

private final static String API_KEY = "INSERT-YOUR-API-KEY-HERE"; /* Sign up at ably.io to get your API key */
Expand All @@ -28,4 +31,10 @@ public Example() {
private void initAbly() throws AblyException {
ablyRest = new AblyRest(API_KEY);
}

/* Add method index with RequestMapping annotation so the web app knows which method to use on our default URL */
@RequestMapping(value = "/")
public String index() {
return "Hello, I am a very simple server";
}
}

0 comments on commit 6d7ce69

Please sign in to comment.