core

package
v0.0.0-...-8d8ec1c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package core - Defines variables/constants and provides utilty functions

Index

Constants

View Source
const (
	// AppName - 어플리케이션 명
	AppName = "cb-restapigw"
	// AppVersion - 어플리케이션 버전
	AppVersion = "0.1.0"
	// AppHeaderName - 어플리케이션 식별을 위한 Header 관리 명
	AppHeaderName = "X-CB-RESTAPIGW"
	// AppUserAgent - Backend 전달에 사용할 User Agent Header 값
	AppUserAgent = AppName + " version " + AppVersion
	// CollectionTag - Backend의 Array를 Json 객체의 데이터로 반환 처리를 위한 Tag Name
	CollectionTag = "collection"
	// WrappingTag - Backend의 Array 직접 반환 처리를 위한 Tag Name
	WrappingTag = "!!wrapping!!"
	// Bypass - Endpoint/Backend Bypass 처리용 식별자
	Bypass = "*bypass"

	// RequestIDKey - Request ID 추적을 위한 Key
	RequestIDKey requestIDKeyType = iota
)

Variables

View Source
var (
	// SimpleURLKeysPattern - 일반적 URL 패턴
	SimpleURLKeysPattern = regexp.MustCompile(`\{([a-zA-Z\-_0-9]+)\}`)
	// SequentialParamsPattern - Sequential 처리용 URL 패턴 (전 수행의 결과를 파라미터로 지정하는 경우)
	SequentialParamsPattern = regexp.MustCompile(`^resp[\d]+_.*$`)
	// DebugPattern - Debug URL 패턴
	DebugPattern = "^[^/]|/__debug(/.*)?$"
	// URLKeyPattern - URL 에 대한 파라미터 처리를 위한 패턴 "{...}"
	URLKeyPattern = regexp.MustCompile(`/\{([a-zA-Z\-_0-9]+)\}`)

	// HOSTPattern - Host URL 패턴
	HOSTPattern = regexp.MustCompile(`(https?://)?([a-zA-Z0-9\._\-]+)(:[0-9]{2,6})?/?`)
)

Functions

func CleanHost

func CleanHost(host string) string

CleanHost - 지정된 호스트에 대해 패턴 검증 및 정리

func CleanHosts

func CleanHosts(hosts []string) []string

CleanHosts - 지정된 호스트들에 대해 호스트 패턴 처리

func CleanPath

func CleanPath(path string) string

CleanPath - 지정된 URI Path에 대해 정리

func ContainsString

func ContainsString(s []string, v string) bool

ContainsString returns true if a string is present in a iteratee.

func ContextWithSignal

func ContextWithSignal(ctx context.Context) context.Context

ContextWithSignal - OS Interrupt signal 연계 처리를 위한 Context 구성

func ExtractPlaceHoldersFromURLTemplate

func ExtractPlaceHoldersFromURLTemplate(subject string, pattern *regexp.Regexp) []string

ExtractPlaceHoldersFromURLTemplate - URL에 설정되어 있는 Placeholder를 추출한 문자열들 반환

func FromJSON

func FromJSON(data string, target interface{}) error

FromJSON - 지정한 JSON 문자열을 지정한 struct로 변환

func GCD

func GCD(x, y int) int

GCD - 지정한 두개의 숫자에 대한 최대 공약수 계산

func GetBool

func GetBool(data map[string]interface{}, key string) bool

GetBool - 지정된 맵 데이터에서 지정한 키에 해당하는 데이터를 bool 으로 반환

func GetClientIPHelper

func GetClientIPHelper(req *http.Request) (string, error)

GetClientIPHelper - Request 기반의 Client IP를 검증

func GetInt64

func GetInt64(data map[string]interface{}, key string) int64

GetInt64 - 지정된 맵 데이터에서 지정한 키에 해당하는 데이터를 int64 로 반환

func GetLastPart

func GetLastPart(source, seperater string) string

GetLastPart - 지정한 문자열을 지정한 문자로 분리하고 마지막 부분 반환

func GetParameteredPath

func GetParameteredPath(path string, params []string) string

GetParameteredPath - 지정된 URI Path에 대해 파라미터를 설정

func GetResponseString

func GetResponseString(resp *http.Response) (string, error)

GetResponseString - http.Response Body를 문자열로 반환

func GetString

func GetString(data map[string]interface{}, key string) string

GetString - 지정된 맵 데이터에서 지정한 키에 해당하는 데이터를 string 으로 반환

func GetStrings

func GetStrings(data map[string]interface{}, name string) []string

GetStrings - 지정된 맵 데이터에서 지정된 이름에 해당하는 데이터를 []string 으로 반환

func IsZeroOfUnderlyingType

func IsZeroOfUnderlyingType(t interface{}) bool

IsZeroOfUnderlyingType - 지정한 형식의 Zero Value 상태인지 검증

func JSONDecode

func JSONDecode(source io.Reader, target interface{}) error

JSONDecode - 지정한 Source의 JSON 정보를 지정한 Target으로 설정

func JSONMarshal

func JSONMarshal(data interface{}) ([]byte, error)

JSONMarshal - 지정한 정보를 JSON 으로 Marshal 처리

func JSONUnmarshal

func JSONUnmarshal(source []byte, target interface{}) error

JSONUnmarshal - 지정한 JSON 문자열 Byte를 지정한 Target으로 설정

func NewWrappedError

func NewWrappedError(code int, message string, originalError error) error

NewWrappedError - 원본 오류를 관리하는 오류 생성

func ParameterExtractPattern

func ParameterExtractPattern(disableStrictREST bool) *regexp.Regexp

ParameterExtractPattern - 파라미터 추출에 사용할 패턴 반환

func RemoveSlice

func RemoveSlice(arr []interface{}, idx int) []interface{}

RemoveSlice - 지정한 배열 구조에서 지정한 인덱스의 값을 삭제하고 반환

func ToJSON

func ToJSON(data interface{}) string

ToJSON - 지정 정보를 JSON 문자열로 변환

Types

type StringInterfaceMap

type StringInterfaceMap map[string]interface{}

StringInterfaceMap - 문자열 인자를 가기는 interface{} Map 형식

type WrappedError

type WrappedError struct {
	// contains filtered or unexported fields
}

WrappedError - 원본 오류를 관리하는 오류 형식

func (WrappedError) Code

func (we WrappedError) Code() int

Code - Wrapping된 오류 코드 반환

func (WrappedError) Error

func (we WrappedError) Error() string

Error - 오류 메시지 반환

func (WrappedError) GetError

func (we WrappedError) GetError() error

GetError - 원본 오류 반환

Directories

Path Synopsis
adapters
gin
Package gin - GIN 기반으로 표준 HTTP 연계 기능을 제공하는 패키지
Package gin - GIN 기반으로 표준 HTTP 연계 기능을 제공하는 패키지
atomic - 각 데이터 형식에 대한 Atomic 제공 패키지
atomic - 각 데이터 형식에 대한 Atomic 제공 패키지
Package defaults - Golang Structure에 Defaults 값 설정 기능 제공 패키지 Package defaults -
Package defaults - Golang Structure에 Defaults 값 설정 기능 제공 패키지 Package defaults -
flatmap
Package rand - Fast Random 기능 제공 패키지
Package rand - Fast Random 기능 제공 패키지

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL