jeroenwijdemans / jaxrs-standard

JAXRS lib that provides Config mangement, Healthcheck, Security filter and CORS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Work in progress

Codacy Badge Build Status License: MIT codecov

JAXRS standard library

provides opinionated utility classes for JAXRS project.

Add the following:

  • Config
  • CORS Filter
  • Healthcheck
  • Immediate Feature
  • Security Filter

Config

Configuration is intended to read yaml, for example on Kubernetes

CORS Filter

Register domains for this service from Config to easily check CORS without using *

Health checks

Quick check to see if the JAXRS is up (note that this does not need to imply your app is really in working order)

Immediate Feature

JAXRS feature that enable the usage of the @Immediate annotation. This annotation makes sure that the class is eagerly initialized in HK2

Security filter

Simple check that:

  • checks if security is needed (in Config)
  • reads a JWT token
  • Validates the token

Dependencies

Expected the following on the classpath:

  • jaxrs implementation
  • javax inject implementation
  • javax annotation implementation
  • hk2-api implementation
  • swagger annotation implementation
  • jackson implementation

JAXRS 2.0 is the reference implementation that works.

Microservice template is a reference implementation for, amongst others, this library.

Usage

Build

Include dependency:

dependencies {
    compile "com.wijdemans:jaxrs-standard:1.0.0"
}

gradle run

To run a task from Gradle we need to add PROPERTIES_LOCATION to the environment.

task(run, dependsOn: 'classes', type: JavaExec) {
    environment 'PROPERTIES_LOCATION', file('./properties/local').absolutePath
    main = 'com.wijdemans.Main'
    classpath = sourceSets.main.runtimeClasspath
}

Add to container:

class Main {
    
    private ResourceConfig createResourceConfig () {
        
        final ResourceConfig rc = new ResourceConfig();
        rc.register(JaxRsErrorMapper.class);
        
        return rc;
    }  
        
}

About

JAXRS lib that provides Config mangement, Healthcheck, Security filter and CORS

License:MIT License


Languages

Language:Java 88.0%Language:Groovy 9.0%Language:Shell 3.0%