restfeed-server-spring

REST Feed server Spring support

License

License

GroupId

GroupId

org.restfeeds
ArtifactId

ArtifactId

restfeed-server-spring
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

restfeed-server-spring
REST Feed server Spring support
Project URL

Project URL

https://github.com/rest-feeds/rest-feeds
Source Code Management

Source Code Management

http://github.com/rest-feeds/restfeed-server-spring/tree/master

Download restfeed-server-spring

How to add to project

<!-- https://jarcasting.com/artifacts/org.restfeeds/restfeed-server-spring/ -->
<dependency>
    <groupId>org.restfeeds</groupId>
    <artifactId>restfeed-server-spring</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.restfeeds/restfeed-server-spring/
implementation 'org.restfeeds:restfeed-server-spring:0.0.1'
// https://jarcasting.com/artifacts/org.restfeeds/restfeed-server-spring/
implementation ("org.restfeeds:restfeed-server-spring:0.0.1")
'org.restfeeds:restfeed-server-spring:jar:0.0.1'
<dependency org="org.restfeeds" name="restfeed-server-spring" rev="0.0.1">
  <artifact name="restfeed-server-spring" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.restfeeds', module='restfeed-server-spring', version='0.0.1')
)
libraryDependencies += "org.restfeeds" % "restfeed-server-spring" % "0.0.1"
[org.restfeeds/restfeed-server-spring "0.0.1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-web jar 2.2.2.RELEASE
org.springframework.boot : spring-boot-starter-jdbc Optional jar 2.2.2.RELEASE
org.springframework.boot : spring-boot-starter-security Optional jar 2.2.2.RELEASE
org.restfeeds : restfeed-server jar 0.0.2

test (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.2.2.RELEASE
org.springframework.security : spring-security-test jar
com.h2database : h2 jar 1.4.200

Project Modules

There are no modules declared in this project.

restfeed-server-spring

Maven Central

Spring Boot support for a REST Feed server endpoint.

Getting Started

Go to start.spring.io and create an new application. Select these dependencies:

  • Spring Web (to provide an HTTP endpoint)
  • JDBC API (for database connectivity)

for testing, you might also want to add

  • H2 Database

Then add this library to your pom.xml:

    <dependency>
      <groupId>org.restfeeds</groupId>
      <artifactId>restfeed-server-spring</artifactId>
      <version>0.0.1</version>
    </dependency>

The RestFeedServerAutoConfiguration adds all relevant beans.

Add these properties to your application.properties:

restfeed.server.feed=myfeed
restfeed.server.path=/myfeed
restfeed.server.limit=1000
restfeed.server.jdbc.table=feed

Next, make sure to have a valid schema for you database set up (use Flyway or the schema.sql file):

create table feed
(
    position identity primary key,
    id       varchar(1024) not null,
    type     varchar(1024),
    resource varchar(1024),
    method   varchar(1024),
    timestamp timestamp,
    data      clob
);

and make sure your database is connected in your application.properties:

spring.datasource.url=jdbc:h2:mem:testdb

Finally, make sure that your application adds new feed items by calling the FeedItemRepository#append method.

feedItemRepository.append(
    "myfeed",
    UUID.randomUUID().toString(),
    "application/vnd.org.example.resource",
    "/myresource/123",
    "PUT",
    Instant.now().toString(),
    data);

When you start the application, you can connect to http://localhost:8080/myfeed.

Find a fully working example at https://github.com/rest-feeds/rest-feed-server-example-spring-web.

Security

Basic Auth is optionally supported.

Add the spring-boot-starter-security dependency to your pom.xml:

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

and specify a username and password in your application.properties:

# alice:secure123
restfeed.server.credentials[0].username=alice
restfeed.server.credentials[0].password={bcrypt}$2a$10$WWJ/p6BOga2R5TRb2LIy4OzlPNiwNM0/aikVKuQ74dKgs67xLIeGS

The password should be encoded, e. g. with BCrypt.

Versions

Version
0.0.1