Last active
June 10, 2018 17:01
-
-
Save juancho088/028a774dd805b5fd78318d17eaa978fc to your computer and use it in GitHub Desktop.
Models for the Request-Dispatcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myblockbuster.core | |
import com.amazonaws.services.lambda.runtime.Context | |
import java.io.Serializable | |
/** | |
* Generic Model that any body in the future should reply to | |
*/ | |
interface Model: Serializable { | |
var id: Int? | |
} | |
/** | |
* In case of no model this is the default model reply | |
*/ | |
class EmptyModel(override var id: Int? = null) : Model | |
/** | |
* In case of error this is the Default Error model to return | |
*/ | |
class ErrorModel(var message: String): Model { | |
override var id: Int? | |
get() = null | |
set(value) {} | |
constructor(): this("") | |
} | |
/** | |
* Represents a client Request | |
* @property input JSON object with all the request data described in https://serverless.com/framework/docs/providers/aws/events/apigateway/ | |
* @property context Lambda function Metadata | |
*/ | |
interface Request { | |
var input: Map<String, Any> | |
var context: Context | |
} | |
/** | |
* Request Dispatcher route to a concrete function based on a regex | |
* @property regex Regex that needs to satisfy to route the request | |
* @property func Function name to be executed | |
* @property cls ClassPath | |
* @constructor Creates an empty object with empty values | |
*/ | |
data class Route(var regex: String, var func: String, var cls: String) { | |
constructor(): this("", "", "") | |
} | |
/** | |
* List of routes | |
* @property List of routes | |
* @constructor emptyList | |
*/ | |
data class Routes(var routes: List<Route>) { | |
constructor(): this(emptyList()) | |
} | |
/** | |
* Represents an APIGateway Request (implements {@link Request}) | |
* @property input JSON object with all the request data described in https://serverless.com/framework/docs/providers/aws/events/apigateway/ | |
* @property context Lambda function Metadata | |
*/ | |
class ApiGatewayRequest(override var input:Map<String, Any>, override var context: Context): Request |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment