-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #768 from tmobile/develop
Release - v1.13
- Loading branch information
Showing
25 changed files
with
687 additions
and
158 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package main | ||
|
||
/** | ||
Go Template Project | ||
@module: configModule | ||
@description: Defines functions for Loading the right Configuration files to get loaded. | ||
@author: | ||
@version: 1.0 | ||
**/ | ||
|
||
|
||
import ( | ||
"github.com/spf13/viper" | ||
"context" | ||
"os" | ||
"strings" | ||
) | ||
|
||
type Config struct { | ||
ctx context.Context | ||
event map[string]interface{} | ||
} | ||
|
||
// Load Configuration file | ||
func (c *Config) LoadConfiguration(ctx context.Context, event map[string]interface{}) { | ||
c.ctx = ctx | ||
c.event = event | ||
|
||
var stage string | ||
var FunctionName string | ||
|
||
if value, ok := event["stage"]; ok { | ||
//get stage value from payload | ||
stage = value.(string) | ||
} else { | ||
// get Function name from Environment Variables | ||
FunctionName = os.Getenv("AWS_LAMBDA_FUNCTION_NAME") | ||
fnName := string(FunctionName [strings.LastIndex(FunctionName , "-") + 1 :len(FunctionName )]) | ||
if (strings.HasPrefix(fnName, "dev")){ | ||
stage = "dev" | ||
}else if (strings.HasPrefix(fnName, "stg")){ | ||
stage = "stg" | ||
}else if (strings.HasPrefix(fnName, "prod")){ | ||
stage = "prod" | ||
} | ||
} | ||
|
||
if len(stage) > 0 { | ||
viper.SetConfigFile("./config/"+stage+"-config.json") | ||
// Searches for config file in given paths and read it | ||
if err := viper.ReadInConfig(); err != nil { | ||
logger.ERROR("Error reading config file ") | ||
} | ||
}else{ | ||
logger.ERROR("Error! No stage Defined") | ||
} | ||
} | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package main | ||
|
||
// /** | ||
// Go Template Project | ||
// @module: errorhandler | ||
// @description: Defines functions raising API Errors in required format for API Gateway integration | ||
// @author: | ||
// @version: 1.0 | ||
// **/ | ||
|
||
// Handle Input Validation error | ||
type InputValidationError struct { | ||
message string | ||
} | ||
|
||
func NewInputValidationError(message string) *InputValidationError { | ||
return &InputValidationError{ | ||
message: message, | ||
} | ||
} | ||
|
||
func (e *InputValidationError) Error() string { | ||
return e.message | ||
} | ||
|
||
// Handle ForbiddenError | ||
type ForbiddenError struct { | ||
message string | ||
} | ||
|
||
func NewForbiddenError(message string) *ForbiddenError { | ||
return &ForbiddenError{ | ||
message: message, | ||
} | ||
} | ||
|
||
func (e *ForbiddenError) Error() string { | ||
return e.message | ||
} | ||
|
||
// Unauthorized Error | ||
type UnauthorizedError struct { | ||
message string | ||
} | ||
|
||
func NewUnauthorizedError(message string) *UnauthorizedError { | ||
return &UnauthorizedError{ | ||
message: message, | ||
} | ||
} | ||
|
||
func (e *UnauthorizedError) Error() string { | ||
return e.message | ||
} | ||
// NotFound Error | ||
type NotFoundError struct { | ||
message string | ||
} | ||
|
||
func NewNotFoundError(message string) *NotFoundError { | ||
return &NotFoundError{ | ||
message: message, | ||
} | ||
} | ||
|
||
func (e *NotFoundError) Error() string { | ||
return e.message | ||
} | ||
|
||
// InternalServerError Error | ||
type InternalServerError struct { | ||
message string | ||
} | ||
|
||
func NewInternalServerError(message string) *InternalServerError { | ||
return &InternalServerError{ | ||
message: message, | ||
} | ||
} | ||
|
||
func (e *InternalServerError) Error() string { | ||
return e.message | ||
} |
Oops, something went wrong.