context

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

README

Request Context

각 요청마다 생성되는 콘텍스트

  • 트랜잭션
  • DB 커넥션 풀
  • 현재 리소스 - 이름, 오너, 권한 등
  • 현재 접속자(쿠키, 세션, 토큰)
  • 접속자의 권한
  • 에러
  • 결과 타입(html, txt, excel, json ...)

Documentation

Index

Constants

View Source
const (
	PersistedResourceType        = "resource.type.persisted"
	HandlerFuncResourceType      = "resource.type.handlerFunc"
	GroupHandlerFuncResourceType = "resource.type.groupHandlerFunc"
)

Variables

View Source
var ErrResourceInvalid = errors.New("resource invalid")

Functions

This section is empty.

Types

type Application added in v0.2.10

type Application interface {
	AddPersistedResource(interface{}) Resource
	AddAllPersistedResource(...interface{}) []Resource
	SetRepository(repository database.Repository)
	Repository() database.Repository
	SetNodeNumber(number int64)
	NodeNumber() int64
	SetDebug(b bool)
	Debug() bool
	ResourceInterfaces() ([]interface{}, error)
	SetIDGenerators(idGenerators generators.IDGenerators)
	Generators() *generators.IDGenerators
	Router
	InitRoute(*echo.Echo, AssignFunc) error

	// event notifier
	SetEventNotifier(notifierMap *owlbear.NotifierMap)
	Notifier
}

어플리케이션 레벨 콘텍스트, 싱글톤

func App added in v0.2.10

func App() Application

type AssignFunc added in v0.3.1

type AssignFunc func(ctx Application, logicArray ...RequestHandlerFunc) echo.HandlerFunc

type Binder

type Binder interface {
	Bind(i interface{}) error
	Param(string) string
	QueryParam(name string) string
}

type HandlerFuncResource

type HandlerFuncResource struct {
	Resource
	Method      string
	Path        string
	HandlerFunc []RequestHandlerFunc
}

type HandlerSetter added in v0.1.1

type HandlerSetter interface {
	Handlers() []HandlerFuncResource
	GET(path string, handlerFunc ...RequestHandlerFunc)
	POST(path string, handlerFunc ...RequestHandlerFunc)
	PUT(path string, handlerFunc ...RequestHandlerFunc)
	DELETE(path string, handlerFunc ...RequestHandlerFunc)
	PATCH(path string, handlerFunc ...RequestHandlerFunc)
	TRACE(path string, handlerFunc ...RequestHandlerFunc)
	OPTION(path string, handlerFunc ...RequestHandlerFunc)
	HEAD(path string, handlerFunc ...RequestHandlerFunc)
	CONNECT(path string, handlerFunc ...RequestHandlerFunc)
	AddHandler(path string, method string, handlerFunc ...RequestHandlerFunc)
}

type Notifier added in v0.2.3

type Notifier interface {
	Subscribe(string, owlbear.NotificationCallback) (chan owlbear.Event, int64)
	Unsubscribe(string, int64)
	Notify(string, interface{})
}

type Request

type Request struct {
	Resource        interface{}
	ResourceName    string
	ResourceOwnerID int64
	Grant           string

	Notify func(string, interface{})
	// contains filtered or unexported fields
}

func New

func New(ctx echo.Context) *Request

func NewWithDB

func NewWithDB(ctx echo.Context, writer *gorm.DB, reader *gorm.DB) *Request

func (*Request) Bind

func (r *Request) Bind(i interface{}) error

func (*Request) Complete

func (r *Request) Complete(c echo.Context) error

func (*Request) CompleteTx

func (r *Request) CompleteTx() error

func (*Request) Context

func (r *Request) Context() echo.Context

func (*Request) HandlerError

func (r *Request) HandlerError() error

func (*Request) JSON added in v0.2.4

func (r *Request) JSON(httpCode int, result interface{}) error

func (*Request) NoContent added in v0.2.5

func (r *Request) NoContent(httpCode int) error

func (*Request) OnPanic

func (r *Request) OnPanic()

func (*Request) Param added in v0.2.4

func (r *Request) Param(name string) string

func (*Request) QueryParam added in v0.2.4

func (r *Request) QueryParam(name string) string

func (*Request) Reader

func (r *Request) Reader() *gorm.DB

func (*Request) Request added in v0.3.1

func (r *Request) Request() *http.Request

func (*Request) Response added in v0.2.2

func (r *Request) Response() http.ResponseWriter

func (*Request) RollbackOnPanic

func (r *Request) RollbackOnPanic()

func (*Request) RollbackTx

func (r *Request) RollbackTx() error

func (*Request) Run

func (r *Request) Run(logic RequestHandlerFunc) error

func (*Request) RunAll

func (r *Request) RunAll(logic []RequestHandlerFunc) error

func (*Request) SaveSession

func (r *Request) SaveSession(scn string, clientCookieName string, domain string) error

func (*Request) SendComplete added in v0.2.9

func (r *Request) SendComplete(c bool)

func (*Request) SendResponse added in v0.3.1

func (r *Request) SendResponse() error

func (*Request) SetTxError

func (r *Request) SetTxError(err error)

func (*Request) StartTx

func (r *Request) StartTx(db *gorm.DB) *gorm.DB

func (*Request) Tx

func (r *Request) Tx() *gorm.DB

func (*Request) TxError

func (r *Request) TxError() error

func (*Request) Writer

func (r *Request) Writer() *gorm.DB

type RequestHandlerFunc

type RequestHandlerFunc func(c *Request) error

type Resource

type Resource struct {
	Name         string
	Type         interface{}
	ResourceType string
}
# 어플리케이션 리소스

어플리케이션에서 사용되는 리소스들, 권한 관리라든가 여러 API 사용할 때 필요하다

type ResponseWriter

type ResponseWriter interface {
	Complete(c echo.Context) error
	JSON(httpCode int, result interface{}) error
	SendComplete(c bool)
}

type RouteGroup added in v0.1.1

type RouteGroup interface {
	Group(path string) Router
	JoinedPath(pathString string) string
	AddGroupHandler(handlerFunc ...RequestHandlerFunc)
	GroupHandlers() []RequestHandlerFunc
}

type Router

type Router interface {
	HandlerSetter
	RouteGroup
	Assign(e *echo.Echo, ctx Application, assignFunc AssignFunc, handlers ...RequestHandlerFunc) error
}

type Runner

type Runner interface {
	Run(logic RequestHandlerFunc) error
	RunAll(logic []RequestHandlerFunc) error
	OnPanic()
}

type SessionCookiePopulateFunc added in v0.3.10

type SessionCookiePopulateFunc func(c echo.Context, r *Request, ctx Application) error

type SessionCookieWriterFunc added in v0.3.1

type SessionCookieWriterFunc func(r *Request, ctx Application) error

type TxRequest

type TxRequest interface {
	database.Repository
	StartTx(db *gorm.DB) *gorm.DB
	CompleteTx() error
	RollbackTx() error
	Tx() *gorm.DB
	TxError() error
	SetTxError(error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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