process

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminAuth

func AdminAuth(c *gin.Context)

func CreateRequestMap

func CreateRequestMap(c *gin.Context, model *APIDataModel) map[string]interface{}

func MakeParamValuer

func MakeParamValuer(jsonConfig string, vars []string) map[string]Valuer

func ProcessIP

func ProcessIP(c *gin.Context, useJSON bool)

ProcessIP process ip request.

Types

type APIDataModel

type APIDataModel struct {
	ID          ID     `json:"id" form:"id"`
	Endpoint    string `json:"endpoint" form:"endpoint"`
	Method      string `json:"method" form:"method"`
	MimeType    string `json:"mimeType"`
	Filename    string `json:"filename"`
	FileContent []byte `json:"-"`
	Body        string `json:"body"`

	ServeFn gin.HandlerFunc `json:"-"`
	// contains filtered or unexported fields
}

APIDataModel ...

func (APIDataModel) CreateJsTreeModel

func (a APIDataModel) CreateJsTreeModel() JsTreeDataModel

func (APIDataModel) HandleFileDownload

func (a APIDataModel) HandleFileDownload(c *gin.Context)

func (APIDataModel) HandleJSON

func (a APIDataModel) HandleJSON(c *gin.Context)

func (*APIDataModel) InternalProcess

func (a *APIDataModel) InternalProcess(subRouter string)

func (*APIDataModel) TryDo

func (a *APIDataModel) TryDo(f func(m *APIDataModel))

type AuthResultType

type AuthResultType int
const (
	AuthResultIgnore AuthResultType = iota
	AuthResultOK
	AuthResultFailed
)

type ContextKey

type ContextKey int

ContextKey as context key type.

const RouterResultKey ContextKey = iota

RouterResultKey as RouterResult key

type DynamicValue

type DynamicValue struct {
	Condition string            `json:"condition"`
	Response  json.RawMessage   `json:"response"`
	Status    int               `json:"status"`
	Headers   map[string]string `json:"headers"`

	Expr                *vm.Program
	ParametersEvaluator map[string]Valuer
}

DynamicValue works for dynamic processing.

type Endpoint

type Endpoint struct {
	ID          uint64 `name:"id" storm:"id,increment"`
	Endpoint    string `name:"endpoint" storm:"unique"`
	Methods     string `name:"methods"`
	MimeType    string `name:"mime_type"`
	Filename    string `name:"filename"`
	Body        string `name:"body"`
	FileContent []byte `name:"file_content"`
	CreateTime  string `name:"create_time"`
	UpdateTime  string `name:"update_time"`
	DeletedAt   string `name:"deleted_at"`
}

Endpoint is the structure for table httplive_endpoint.

func (*Endpoint) CreateDefault

func (ep *Endpoint) CreateDefault(m *APIDataModel)

func (*Endpoint) CreateDirect

func (ep *Endpoint) CreateDirect(m *APIDataModel)

func (*Endpoint) CreateEcho

func (ep *Endpoint) CreateEcho(m *APIDataModel)

func (*Endpoint) CreateMockbin

func (ep *Endpoint) CreateMockbin(m *APIDataModel)

func (Endpoint) CreateProxy

func (ep Endpoint) CreateProxy(m *APIDataModel)

type ID

type ID string

ID is the ID for UnmarshalJSON from integer.

func (ID) Int

func (i ID) Int() uint64

Int convert ID to integer.

func (*ID) UnmarshalJSON

func (i *ID) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals JSON from integer or string.

type IP

type IP struct {
	Country   string `json:"country"`
	CountryID string `json:"country_id"`
	Area      string `json:"area"`
	AreaID    string `json:"area_id"`
	Region    string `json:"region"`
	RegionID  string `json:"region_id"`
	City      string `json:"city"`
	CityID    string `json:"city_id"`
	Isp       string `json:"isp"`
}

IP ...

type Info

type Info struct {
	Code int `json:"code"`
	Data IP  `json:"data"`
}

Info ...

func TabaoAPI

func TabaoAPI(ip string) *Info

TabaoAPI ...

type JsTreeDataModel

type JsTreeDataModel struct {
	ID        int               `json:"id"`
	Key       string            `json:"key"`
	OriginKey string            `json:"originKey"`
	Text      string            `json:"text"`
	Type      string            `json:"type"`
	Children  []JsTreeDataModel `json:"children"`
}

JsTreeDataModel ...

type Mockbin

type Mockbin struct {
	Status      int               `json:"status"`
	Method      string            `json:"method"`
	RedirectURL string            `json:"redirectURL"`
	Headers     map[string]string `json:"headers"`
	Cookies     []MockbinCookie   `json:"cookies"`
	Close       bool              `json:"close"`
	ContentType string            `json:"contentType"`
	Payload     json.RawMessage   `json:"payload"`
	Sleep       string            `json:"sleep"`
}

Mockbin defines the mockbin struct.

func (Mockbin) Handle

func (m Mockbin) Handle(c *gin.Context)

func (Mockbin) IsValid

func (m Mockbin) IsValid() bool

IsValid tells the mockbin is valid or not.

func (Mockbin) Redirect

func (m Mockbin) Redirect(c *gin.Context)

type MockbinCookie

type MockbinCookie struct {
	Name     string `json:"name"`
	Value    string `json:"value"`
	MaxAge   int    `json:"maxAge"`
	Path     string `json:"path"`
	Domain   string `json:"domain"`
	Secure   bool   `json:"secure"`
	HTTPOnly bool   `json:"httpOnly"`
	SameSite string `json:"sameSite"`
}

MockbinCookie defines the cookie format.

func (MockbinCookie) SetCookie

func (v MockbinCookie) SetCookie(c *gin.Context)

type RouterResult

type RouterResult struct {
	RouterServed   bool
	RouterBody     []byte
	Filename       string
	ResponseHeader map[string]string
	ResponseStatus int
	ResponseSize   int
	RemoteAddr     string
}

RouterResult result for router

type Valuer

type Valuer func(reqBody []byte, c *gin.Context) interface{}

type WsMessage

type WsMessage struct {
	Time           string            `json:"time"`
	Host           string            `json:"host"`
	Body           interface{}       `json:"body"`
	Response       json.RawMessage   `json:"response"`
	ResponseStatus int               `json:"status"`
	ResponseHeader map[string]string `json:"responseHeader"`
	ResponseSize   int               `json:"responseSize"`
	Header         map[string]string `json:"header"`
	Method         string            `json:"method"`
	Path           string            `json:"path"`
	Query          map[string]string `json:"query"`
	RemoteAddr     string            `json:"remoteAddr"`
}

WsMessage ...

Jump to

Keyboard shortcuts

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