httpx

package
v0.0.0-...-8c2001a Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MessageOk = []byte(`{"message": "success"}`)
)

Functions

func ApiBaseURL

func ApiBaseURL(host, tenantId string) string

func NotFound

func NotFound(ctx *gin.Context)

func ReadForm

func ReadForm(ctx *gin.Context) ([]byte, error)

func UnAuthorized

func UnAuthorized(ctx *gin.Context)

func WriteBinary

func WriteBinary(c *gin.Context, data []byte)

func WriteErr

func WriteErr(c *gin.Context, err error)

func WriteErrString

func WriteErrString(c *gin.Context, msg string)

func WriteFile

func WriteFile(file string, data []byte, ctx *gin.Context)

func WriteFinal

func WriteFinal(c *gin.Context, err error)

func WriteJSON

func WriteJSON(c *gin.Context, resp any, err error)

func WriteOk

func WriteOk(c *gin.Context)

Types

type Adapter

type Adapter interface {
	ServeEditorFile(file string) ([]byte, error)

	PreformEditorAction(ctx AdapterEditorContext) (any, error)

	Handle(ctx Context)

	Close() error
}

type AdapterEditorContext

type AdapterEditorContext struct {
	Id   int64
	User *claim.UserContext
	Name string
	Data []byte
}

type AdapterHandle

type AdapterHandle interface {
	GetLogger() *zerolog.Logger

	LogInfo(rid int64) *zerolog.Event

	LogError(rid int64) *zerolog.Event

	SelfReset()
}

type AdapterHub

type AdapterHub interface {
	Serve(ctx *gin.Context)

	IsAllowed(tenantId, host string) bool

	ApplyTargetHook(tenantId string, id int64, data *entities.TargetHook)

	ApplyAdapter(tenantId string, id int64, data *entities.TenantDomain)

	PreformEditorAction(ctx AdapterEditorContext) (any, error)

	ListAdapters() []string

	ServeEditorFile(tenantId, file string, did int64, ctx *gin.Context)

	ServePublic(file string, ctx *gin.Context)
}

type Builder

type Builder func(opts BuilderOptions) (Adapter, error)

type BuilderOptions

type BuilderOptions struct {
	App      xtypes.App
	TenantId string
	Domain   *entities.TenantDomain
	Handle   AdapterHandle
	Cache    GlobalCache
}

type CacheLoader

type CacheLoader interface {
	Has(key string) (bool, error)
	Get(dst io.Writer, key string) error
	Put(key string, src io.Reader) error
}

type Context

type Context struct {
	Rid  int64
	Http *gin.Context
}

type GlobalCache

type GlobalCache interface {
	GetSubCache(key string, loader CacheLoader) (SubCache, error)
}

type Request

type Request struct {
	Id      int64
	Http    *gin.Context
	Session *claim.Session
}

func (Request) MustParam

func (r Request) MustParam(name string) string

func (Request) MustParamInt

func (r Request) MustParamInt(name string) int64

func (Request) MustQuery

func (r Request) MustQuery(name string) string

func (Request) MustQueryInt

func (r Request) MustQueryInt(name string) int64

type Rutil

type Rutil struct{}

func (*Rutil) WriteErr

func (r *Rutil) WriteErr(c *gin.Context, msg string)

func (*Rutil) WriteFinal

func (r *Rutil) WriteFinal(c *gin.Context, err error)

func (*Rutil) WriteJSON

func (r *Rutil) WriteJSON(c *gin.Context, resp any, err error)

type SubCache

type SubCache interface {
	Has(key string) (bool, error)
	Get(dst io.Writer, key string) error
}

Jump to

Keyboard shortcuts

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