handler

package
v0.0.0-...-6279077 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RESPONSE_CREATED_SUCCESS = "RESPONSE_CREATED_SUCCESS"
	RESPONSE_SUCCESS_UPDATED = "RESPONSE_SUCCESS_UPDATED"
	RESPONSE_SUCCESS         = "RESPONSE_SUCCESS"
)

* const that defined with key on configuration json/messages.json

Variables

This section is empty.

Functions

func GetRawURL

func GetRawURL(url string, params gin.Params) string

* create raw URL from current URL binding with gin.Params and replacing with the key

func ResponseError

func ResponseError(body interface{}, c *gin.Context, message *exception.ErrorException)

generate response error with return ErrorException model

func ResponseOk

func ResponseOk(body interface{}, c *gin.Context, ressMessage *ResponseInfo)

generate response ok with custom http code

func SpaceMap

func SpaceMap(str string) string

remove whitespace

func ValidateRequest

func ValidateRequest(req interface{}) *exception.ErrorException

* validating Object struct with govalidator rule

Types

type BodyLogWriter

type BodyLogWriter struct {
	gin.ResponseWriter
	Body *bytes.Buffer
}

func (BodyLogWriter) Write

func (w BodyLogWriter) Write(b []byte) (int, error)

type LogRequest

type LogRequest struct {
	RequestId    string        `json:"request_id"`
	Header       interface{}   `json:"header"`
	Method       string        `json:"method"`
	Url          string        `json:"url"`
	Body         interface{}   `json:"body"`
	HttpCode     int           `json:"http_code"`
	Latency      time.Duration `json:"latency"`
	ResponseBody interface{}   `json:"response_body"`
}

type MessageHelper

type MessageHelper interface {
	Ress(message string) *ResponseInfo
}

type ResponseInfo

type ResponseInfo struct {
	Info configuration.MessageModel
}

func NewSuccess

func NewSuccess(successMessage string) *ResponseInfo

* creating new success object and return it interface

func (ResponseInfo) Ress

func (ResponseInfo) Ress() *ResponseInfo

* throwing message that defined with the const that exist on key json/messages.json and add some additional information from go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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