io.github.fssantana:vertgo

A tool to ease Lambda Functions development for Applications using Api Gateway.

License

License

BSD
Categories

Categories

Ant Build Tools
GroupId

GroupId

io.github.fssantana
ArtifactId

ArtifactId

vertgo
Last Version

Last Version

1.4.0
Release Date

Release Date

Type

Type

jar
Description

Description

io.github.fssantana:vertgo
A tool to ease Lambda Functions development for Applications using Api Gateway.
Project URL

Project URL

https://github.com/fssantana/vertgo
Project Organization

Project Organization

jcabi.com
Source Code Management

Source Code Management

http://github.com/fssantana/vertgo/tree/master

Download vertgo

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.fssantana/vertgo/ -->
<dependency>
    <groupId>io.github.fssantana</groupId>
    <artifactId>vertgo</artifactId>
    <version>1.4.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.fssantana/vertgo/
implementation 'io.github.fssantana:vertgo:1.4.0'
// https://jarcasting.com/artifacts/io.github.fssantana/vertgo/
implementation ("io.github.fssantana:vertgo:1.4.0")
'io.github.fssantana:vertgo:jar:1.4.0'
<dependency org="io.github.fssantana" name="vertgo" rev="1.4.0">
  <artifact name="vertgo" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.fssantana', module='vertgo', version='1.4.0')
)
libraryDependencies += "io.github.fssantana" % "vertgo" % "1.4.0"
[io.github.fssantana/vertgo "1.4.0"]

Dependencies

compile (9)

Group / Artifact Type Version
io.vertx : vertx-core jar 3.7.0
io.vertx : vertx-web jar 3.7.0
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.6.1
com.google.guava : guava jar 27.1-jre
log4j : log4j jar 1.2.17
com.amazonaws : aws-java-sdk-core jar 1.11.543
com.amazonaws : aws-java-sdk-lambda jar 1.11.543
com.amazonaws : aws-lambda-java-events jar 2.2.4
com.amazonaws : aws-lambda-java-log4j2 jar 1.0.0

test (2)

Group / Artifact Type Version
org.mockito : mockito-core jar 2.21.0
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Vertgo


Build Status

A tool to ease Lambda Functions development for Applications using Api Gateway

About Vertgo


Vertgo is a microframework that provides tools to make it easier to develop api's using the AWS Lambda Function and API Gateway. Lambda Forest attempts to make the development faster by providing a way to create a single Lambda Function to serve multiple endpoints. That is achieved using Vert.x.

Some tools:

  • Routing
  • Serializations for inputs and responses
  • Custom configurations
  • Controller input will be body OR query string parameters (never both)
  • Any bean can be used as input type

How to use:

  • Each controller will have one route associated
  • Caught exceptions will be returned as 500 status code, EXCEPT Vertgo HttpException
public class ExampleController extends Controller<HashMap, LambdaResponse<Map>> {

    /**
    *  route {HTTP_METHOD}:{PATH} 
    */
    @Override
    public String route() {
        return "GET:/users";
    }

    /**
    * Service execution override handle method
    * This method can return any bean or a LambdaResponse<O> instance.
    * If a LambdaResponse instance is returned, you can set status code and headers;
    * If another instance is returned, default status code (200) and empty headers will be returned
    * 
    **/
    @Override
    public LambdaResponse<Map> handle(HashMap input) throws io.github.fssantana.vertgo.exception.HttpException{
        LambdaResponse<Map> response = new LambdaResponse<>();
        response.setBody(Collections.singletonMap("teste", "testeadas"));
        return response;
    }
}
  • Create a Route class wich needs to contains all Controllers you want to use
public class Routes extends VertgoHandler {

    /**
    * All controllers should be here 
    */
    @Override
    protected List<Controller> router() {
        return Arrays.asList(
                new ExampleController()
        );
    }

}

If you want to set a default header value that will go in every response, just override the Route method like this:

public class Routes extends VertgoHandler {

    /**
    * All controllers should be here 
    */
    @Override
    protected List<Controller> router() {
        return Arrays.asList(
                new ExampleController()
        );
    }
    
    /**
    * These headers will be add to every response.
    * Preference is given for LambdaResponse header value in case of conflict
    */
    @Override
    protected Map<String, String> addHeaders(){
        HashMap<String, String> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("aaa", "bbb");
        return objectObjectHashMap;
    }

}

Override filter method to execute before all controllers handlers

public class Routes extends VertgoHandler {
 //...
  protected ControllerFilter filter() {
      return new ControllerFilter() {
        @Override
        public void apply(LambdaRequest request) throws HttpException {
          //Your code here
        }
      };
    }
}

Override filter method to execute before all controllers handlers

public class MyController extends Controller {
 //...
   @Override
    protected void before(){
      //getRawBody();
      //Your code
    }
}

Add as Maven dependency

  • Add as maven dependency
<dependency>
  <groupId>io.github.fssantana</groupId>
  <artifactId>vertgo</artifactId>
  <version>1.4.0</version>
</dependency>

Versions

Version
1.4.0
1.3.0
1.2.2
1.2.1
1.2.0
1.1.0
1.0.1
1.0.0
0.3.0