rest_api

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MIT Imports: 23 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	Endpoint_Root      = "/"
	Endpoint_Static    = "/static"
	Endpoint_Log       = "/log"
	Endpoint_Api       = "/api"
	Endpoint_Docs      = "/docs/:md-doc"
	Endpoint_Api_Slash = "/api/"
	Endpoint_Api_Any   = "/api/*any"
	Endpoint_Api_Index = "/api/index.html"
	Endpoint_Health    = "/health"
	Client_Health      = "/health"
	Param_start_time   = "start_time"
	Param_end_time     = "end_time"
	Param_orderId      = "orderId"
	Param_mdDoc        = "md-doc"
	Param_details      = "details"
	Param_channel      = "channel"

	CHANNEL_API       = "API"
	CHANNEL_TEST_CASE = "TEST_CASE"
	CHANNEL_UNKNOWТ   = "UNKNOWN"
)

Variables

This section is empty.

Functions

func FunctionalNotAllowed

func FunctionalNotAllowed(ctx *gin.Context)

func FunctionalNotImplemented

func FunctionalNotImplemented(ctx *gin.Context)

func HandleError

func HandleError(err error, ctx *gin.Context, log *logger.Logger) bool

func ThrowError

func ThrowError(ctx *gin.Context, status int, err error)

Please, use сtx.AbortWithError Deprecated

Types

type AuthFilter

type AuthFilter struct {
	OAuthClient           *oaut_client.OAuthClient
	Log                   *logger.Logger
	Scope                 string
	Mock                  *AuthFilterMock
	ExcludePath           []string
	SkipCheckMpanPath     []string
	PermanentAccessTokens map[string]interface{}
}

func (AuthFilter) DoAuth

func (this AuthFilter) DoAuth(
	ctx *gin.Context,
)

func (*AuthFilter) HasError

func (this *AuthFilter) HasError(err error, ctx *gin.Context) bool

func (AuthFilter) SkipFilterRules

func (this AuthFilter) SkipFilterRules(context *gin.Context) bool

func (AuthFilter) SkipMpanCheckRules

func (this AuthFilter) SkipMpanCheckRules(context *gin.Context) bool

type AuthFilterMock

type AuthFilterMock struct {
	Mpan string
}

type BaseRestController

type BaseRestController struct {
	Log           *logger.Logger
	ServicePrefix string
}

func (*BaseRestController) CallService

func (this *BaseRestController) CallService(
	ctx *gin.Context,
	restClient *resty.Client,
	servicePath string,
)

Deprecated

func (*BaseRestController) GetBearerAuthToken

func (this *BaseRestController) GetBearerAuthToken(ctx *gin.Context) string

Deprecated

func (*BaseRestController) GetCurrentStatePtr

func (this *BaseRestController) GetCurrentStatePtr(ctx *gin.Context) *rules.CurrentState

func (*BaseRestController) GetMpan

func (this *BaseRestController) GetMpan(ctx *gin.Context) string

func (*BaseRestController) GetTokenInfo

func (this *BaseRestController) GetTokenInfo(ctx *gin.Context) (token interface{}, exists bool)

func (*BaseRestController) IsVerboseDetails

func (this *BaseRestController) IsVerboseDetails(context *gin.Context) bool

func (*BaseRestController) ListEntityesResponse

func (this *BaseRestController) ListEntityesResponse(
	ctx *gin.Context,
	entityName EntityName,
	listIsEmptyMessage string,
	entityId func(interface{}) interface{},
	convertor func(interface{}) interface{},

	entitiesList ...interface{},
)

func (*BaseRestController) PushResponse

func (this *BaseRestController) PushResponse(ctx *gin.Context, response *resty.Response)

func (*BaseRestController) RLogAction

func (this *BaseRestController) RLogAction(ctx *gin.Context, action types.Action) logrus.FieldLogger

func (*BaseRestController) RedirectToService

func (this *BaseRestController) RedirectToService(
	ctx *gin.Context,
	restClient *rest_client.RestClient,
)

func (*BaseRestController) ValidateError

func (this *BaseRestController) ValidateError(err error, ctx *gin.Context) bool

Deprecated

type CommonRestController

type CommonRestController interface {
	GetList(ctx *gin.Context)
	MassUpdate(ctx *gin.Context)
	MassDelete(ctx *gin.Context)
	Get(ctx *gin.Context)
	Create(ctx *gin.Context)
	Update(ctx *gin.Context)
	Delete(ctx *gin.Context)
}

type EntityName

type EntityName string

type HealthApiRestController

type HealthApiRestController struct {
	BaseRestController
	HealthApiService HealthApiService
}

func (*HealthApiRestController) InitController

func (this *HealthApiRestController) InitController()

type HealthApiService

type HealthApiService struct {
	RestClients map[string]*rest_client.RestClient
	OAuthClient *oaut_client.OAuthClient
	Log         *logger.Logger
	ServiceName string
	Versions    map[string]string
}

func (*HealthApiService) AddRestClient

func (this *HealthApiService) AddRestClient(name string, restClient *rest_client.RestClient)

func (*HealthApiService) Health

func (this *HealthApiService) Health() health.Health

type RedirectApiRestController

type RedirectApiRestController struct {
	BaseRestController
	RestClient *rest_client.RestClient `inject:""`
}

func (*RedirectApiRestController) InitController

func (this *RedirectApiRestController) InitController()

func (*RedirectApiRestController) Redirect

func (this *RedirectApiRestController) Redirect(ctx *gin.Context)

type ResponseStatus

type ResponseStatus string
const (
	// for all http code from [100 : 400)
	ResponseStatusSuccess ResponseStatus = "success"
	// for all http code from [400 : 500)
	ResponseStatusFail ResponseStatus = "fail"
	// for all http code from [500 : 600)
	ResponseStatusError ResponseStatus = "error"
)

type RestResponse

type RestResponse struct {
	Version   string         `json:"version,omitempty"`   // Api Version
	DateTime  string         `json:"datetime,omitempty"`  // Human-readable date and time when the event occurred
	Timestamp int64          `json:"timestamp,omitempty"` // Machine-readable UTC timestamp in nanoseconds since EPOCH
	Status    ResponseStatus `json:"status"`              // State code (error|fail|success)
	Code      int            `json:"code"`                // HTTP status code
	Message   string         `json:"message"`             // Error or status message
	Data      interface{}    `json:"data,omitempty"`      // Data payload
	Meta      interface{}    `json:"meta,omitempty"`      // Meta information about reguest
	Errors    interface{}    `json:",omitempty"`          // List errors
}

Rest Response See link https://github.com/omniti-labs/jsend See link https://technick.net/guides/software/software_json_api_format/

func ErrorRestResponse

func ErrorRestResponse(ctx *gin.Context, httpCode int, err error) RestResponse

func FailRestResponse

func FailRestResponse(ctx *gin.Context, httpCode int, message string) RestResponse

func SuccessRestResponse

func SuccessRestResponse(
	ctx *gin.Context,
	httpCode int,
	message string,
	data interface{},
) RestResponse

func SuccessRestResponseEntity

func SuccessRestResponseEntity(
	ctx *gin.Context,
	httpCode int,
	message string,
	entityName EntityName,
	entity interface{},
) RestResponse

type StateFilter

type StateFilter struct {
}

func (StateFilter) DoCurrentSatet

func (this StateFilter) DoCurrentSatet(
	ctx *gin.Context,
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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