api

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VerdictSuccess           = "success"
	VerdictFailure           = "failure"
	VerdictMissingParameters = "missing_parameters"
	VerdictInvalidParameters = "invalid_parameters"
)

Variables

This section is empty.

Functions

func AbortJSON

func AbortJSON(ctx *gin.Context, statusCode int, verdict string, message string, data interface{})

AbortJSON abort with JSON

func Recovery

func Recovery() gin.HandlerFunc

Recovery returns a middleware for a given writer that recovers from any panics and calls the provided handle func to handle it

func RequestIDMiddleware

func RequestIDMiddleware() gin.HandlerFunc

RequestIDMiddleware adds X-Request-ID value to request, response and save to context variable

func RequestTimeMiddleware

func RequestTimeMiddleware() gin.HandlerFunc

RequestTimeMiddleware logs request time

func SendError

func SendError(ctx *gin.Context, _ error)

SendError sends error

func SendJSON

func SendJSON(ctx *gin.Context, statusCode int, verdict string, message string, data interface{})

SendJSON sends JSON

func SendSuccess

func SendSuccess(ctx *gin.Context, message string, data interface{})

SendSuccess sends success response

func SetupContext

func SetupContext()

TODO: This is opinionated solution to register UnwrapContext

Types

type App

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

App defines app interface

func NewApp

func NewApp(ctx context.Context, config *config.Config, options ...AppOption) (*App, error)

NewApp returns new app

func NewInMemoryApp added in v0.0.6

func NewInMemoryApp(ctx context.Context, config *config.Config, options ...AppOption) (*App, error)

NewApp returns new app with memory stub instead of using database

func (*App) Start

func (app *App) Start(ctx context.Context) error

Start starts app

type AppOption

type AppOption func(*App)

type StubRequestParam

type StubRequestParam struct {
	Stubs []*rio.Stub `json:"stubs" yaml:"stubs"`

	// Go SDK expect the response should be encoded data
	ReturnEncoded bool `json:"return_encoded" yaml:"return_encoded"`
}

StubRequestParam stub request

Jump to

Keyboard shortcuts

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