handler

package
v0.0.0-...-2b29b9b Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BM_PREFIX     = "baremetals"
	SERVER_PREFIX = "servers"

	PARAMS_BMID_KEY  = "<bm_id>"
	PARAMS_SRVID_KEY = "<srv_id>"
)

Variables

This section is empty.

Functions

func AddHandler

func AddHandler(app *appsrv.Application, method string, prefix string,
	handler func(context.Context, http.ResponseWriter, *http.Request)) *appsrv.SHandlerInfo

func AddHandler2

func AddHandler2(app *appsrv.Application, method string, prefix string,
	handler func(context.Context, http.ResponseWriter, *http.Request),
	metadata map[string]interface{}, name string, tags map[string]string) *appsrv.SHandlerInfo

func DelayProcess

func DelayProcess(process ProcessFunc, session *mcclient.ClientSession, taskId string, data jsonutils.JSONObject)

func InitHandlers

func InitHandlers(app *appsrv.Application)

Types

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

func NewContext

func NewContext(ctx context.Context, w http.ResponseWriter, r *http.Request) *Context

func (*Context) Data

func (ctx *Context) Data() jsonutils.JSONObject

func (*Context) DelayProcess

func (ctx *Context) DelayProcess(process ProcessFunc, data jsonutils.JSONObject)

func (*Context) GetBaremetalManager

func (ctx *Context) GetBaremetalManager() *baremetal.SBaremetalManager

func (*Context) Params

func (ctx *Context) Params() map[string]string

func (*Context) Query

func (ctx *Context) Query() jsonutils.JSONObject

func (*Context) Request

func (ctx *Context) Request() *http.Request

func (*Context) RequestRemoteIP

func (ctx *Context) RequestRemoteIP() string

func (*Context) ResponseError

func (ctx *Context) ResponseError(err error)

func (*Context) ResponseJson

func (ctx *Context) ResponseJson(obj jsonutils.JSONObject)

func (*Context) ResponseOk

func (ctx *Context) ResponseOk()

func (*Context) ResponseStruct

func (ctx *Context) ResponseStruct(obj interface{})

func (*Context) TaskId

func (ctx *Context) TaskId() string

func (*Context) UserCred

func (ctx *Context) UserCred() mcclient.TokenCredential

type ProcessFunc

type ProcessFunc func(ctx context.Context, data jsonutils.JSONObject) (jsonutils.JSONObject, error)

Jump to

Keyboard shortcuts

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