Documentation
¶
Overview ¶
Package sdecho echo 扩展工具
Index ¶
- Constants
- Variables
- func AccessControlCheck(ctx context.Context, ec echo.Context, token Token, object Object, ...) error
- func CrossOrigin() echo.MiddlewareFunc
- func Get[T any](ec echo.Context, k string) (T, bool)
- func MustGet[T any](ec echo.Context, k string) T
- func MustHtmlRenderer(fsys fs.FS, eager bool) echo.Renderer
- func NewHtmlRenderer(fsys fs.FS, eager bool) (echo.Renderer, error)
- func TokenEncode(_ context.Context, ec echo.Context, t Token) string
- type API
- type AccessControl
- type AccessControlChecker
- type AntdJsonRequest
- func (req *AntdJsonRequest) Fields() []string
- func (req *AntdJsonRequest) Flags() []string
- func (req *AntdJsonRequest) Keyword() string
- func (req *AntdJsonRequest) Page() RequestPage
- func (req *AntdJsonRequest) PageDef(defaultSize int) RequestPage
- func (req *AntdJsonRequest) SetFields(fields []string)
- func (req *AntdJsonRequest) SetFlags(flags []string)
- func (req *AntdJsonRequest) SetPage(page RequestPage)
- type BaseRequest
- type BrowserHistoryRouterStatic
- type CasbinRbac
- type Context
- func (c Context) ArgBool(name string, def bool) bool
- func (c Context) ArgBoolFirst(names []string, def bool) bool
- func (c Context) ArgFloat64(name string, def float64) float64
- func (c Context) ArgFloat64First(names []string, def float64) float64
- func (c Context) ArgInt(name string, def int) int
- func (c Context) ArgInt64(name string, def int64) int64
- func (c Context) ArgInt64First(names []string, def int64) int64
- func (c Context) ArgIntFirst(names []string, def int) int
- func (c Context) ArgString(name, def string) string
- func (c Context) ArgStringFirst(names []string, def string) string
- func (c Context) ArgTime(name string, def time.Time) time.Time
- func (c Context) ArgTimeFirst(names []string, def time.Time) time.Time
- func (c Context) CookieInt(name string, def int) int
- func (c Context) CookieInt64(name string, def int64) int64
- func (c Context) CookieJson(name string, v any) error
- func (c Context) CookieJsonObject(name string, def sdjson.Object) sdjson.Object
- func (c Context) CookieString(name, def string) string
- func (c Context) DeleteCookie(name string, path string)
- func (c Context) HandleMultipartFormFile(files []string, handler func(file FileHeader) error) error
- func (c Context) RequestBodyAs(v any) error
- func (c Context) RequestBodyAsJsonArray() (sdjson.Array, error)
- func (c Context) RequestBodyAsJsonObject() (sdjson.Object, error)
- func (c Context) RequestBodyAsJsonValue() (sdjson.Value, error)
- func (c Context) RequestBodyBytes() ([]byte, error)
- func (c Context) RequestBodyString() (string, error)
- func (c Context) SetCookieInt(name string, val int, path string, maxAge int)
- func (c Context) SetCookieInt64(name string, val int64, path string, maxAge int)
- func (c Context) SetCookieJson(name string, v any, path string, maxAge int) error
- func (c Context) SetCookieString(name, val string, path string, maxAge int)
- type CrudAPI
- type Echo
- type Endpoint
- type Feature
- type FeatureFunc
- type FileHeader
- type FindAPI
- type FindResult
- type Inject
- type ListAPI
- type Menu
- type MenuItem
- type Menus
- type NoRedirectStatic
- type Object
- func (o Object) Expand(mapper any, others ...any) Object
- func (o Object) HasTags() bool
- func (o Object) Id() string
- func (o Object) IsEmpty() bool
- func (o Object) IsExpanded() bool
- func (o Object) IsPublic() bool
- func (o Object) MatchTag(tag string) bool
- func (o Object) MatchTagsAny(tags []string) bool
- func (o Object) String() string
- func (o Object) TagCount() int
- func (o Object) Tags() []string
- type Options
- type Record
- type RecordID
- type RequestPage
- type Result
- func (r *Result) WithCode(code any) *Result
- func (r *Result) WithContentType(contentType string) *Result
- func (r *Result) WithFacade(facade any) *Result
- func (r *Result) WithField(k string, v any) *Result
- func (r *Result) WithFields(fields map[string]any) *Result
- func (r *Result) WithHeader(k, v string) *Result
- func (r *Result) WithHeaders(headers map[string]string) *Result
- func (r *Result) WithHttpStatus(status int) *Result
- func (r *Result) Write(ec echo.Context, opts *ResultOptions) error
- type ResultOptions
- type Routes
- type Token
- type Tokens
- type WebPage
Constants ¶
View Source
const ( ActionCall = "call" ActionShow = "show" )
Variables ¶
View Source
var ( ErrForbidden = sderr.Sentinel("forbidden") ErrBadRequest = sderr.Sentinel("bad request") ErrInternalServerError = sderr.Sentinel("internal server error") ErrDecodeToken = sderr.Sentinel("decode token error") ErrTokenExpired = sderr.Sentinel("token expired") ErrLogin = sderr.Sentinel("login error") )
View Source
var Public = Object{/* contains filtered or unexported fields */}
Functions ¶
func AccessControlCheck ¶
func CrossOrigin ¶
func CrossOrigin() echo.MiddlewareFunc
func MustHtmlRenderer ¶
Types ¶
type API ¶
func (API) ToEndpoint ¶
type AccessControl ¶
type AccessControl struct { Check AccessControlChecker DefaultObjectVars map[string]string }
func (AccessControl) Apply ¶
func (ac AccessControl) Apply(app *echo.Echo) error
type AccessControlChecker ¶
type AntdJsonRequest ¶
type AntdJsonRequest struct { Params sdjson.Object `json:"params,omitempty"` Sort sdjson.Object `json:"sort,omitempty"` Filter sdjson.Object `json:"filter,omitempty"` UpdateFields []string `json:"fields,omitempty"` ShowFlags []string `json:"flags,omitempty"` }
func (*AntdJsonRequest) Fields ¶
func (req *AntdJsonRequest) Fields() []string
func (*AntdJsonRequest) Flags ¶
func (req *AntdJsonRequest) Flags() []string
func (*AntdJsonRequest) Keyword ¶
func (req *AntdJsonRequest) Keyword() string
func (*AntdJsonRequest) Page ¶
func (req *AntdJsonRequest) Page() RequestPage
func (*AntdJsonRequest) PageDef ¶
func (req *AntdJsonRequest) PageDef(defaultSize int) RequestPage
func (*AntdJsonRequest) SetFields ¶
func (req *AntdJsonRequest) SetFields(fields []string)
func (*AntdJsonRequest) SetFlags ¶
func (req *AntdJsonRequest) SetFlags(flags []string)
func (*AntdJsonRequest) SetPage ¶
func (req *AntdJsonRequest) SetPage(page RequestPage)
type BaseRequest ¶
type BaseRequest interface { Page() RequestPage SetPage(page RequestPage) Fields() []string SetFields(fields []string) Flags() []string SetFlags(flags []string) }
type BrowserHistoryRouterStatic ¶
type BrowserHistoryRouterStatic struct { PathPrefix string Fsys fs.FS Root string TrimPathPrefixes []string }
func (BrowserHistoryRouterStatic) Apply ¶
func (d BrowserHistoryRouterStatic) Apply(app *echo.Echo) error
type CasbinRbac ¶
type CasbinRbac struct { Rbac sdcasbin.Rbac CheckToken func(echo.Context, Token) (bool, error) DefaultObjectVars map[string]string }
func (CasbinRbac) Apply ¶
func (ac CasbinRbac) Apply(app *echo.Echo) error
type Context ¶
type Context struct {
echo.Context
}
func (Context) ArgFloat64First ¶
func (Context) ArgTimeFirst ¶
func (Context) CookieJsonObject ¶
func (Context) CookieString ¶
func (Context) DeleteCookie ¶
func (Context) HandleMultipartFormFile ¶
func (c Context) HandleMultipartFormFile(files []string, handler func(file FileHeader) error) error
func (Context) RequestBodyAs ¶
func (Context) RequestBodyAsJsonArray ¶
func (Context) RequestBodyAsJsonObject ¶
func (Context) RequestBodyAsJsonValue ¶
func (Context) RequestBodyBytes ¶
func (Context) RequestBodyString ¶
func (Context) SetCookieInt ¶
func (Context) SetCookieInt64 ¶
func (Context) SetCookieJson ¶
type CrudAPI ¶
type CrudAPI[T Record[ID], ID RecordID, REQ BaseRequest] struct { Path string Create func(echo.Context, T, REQ) (T, error) Update func(echo.Context, T, REQ) (T, error) Delete func(echo.Context, ID, REQ) error Get func(echo.Context, ID, REQ) (T, error) List func(echo.Context, REQ) ([]T, error) Find func(echo.Context, REQ) (*FindResult[T], error) Object Object ObjectR Object ObjectW Object Middlewares []echo.MiddlewareFunc }
func (CrudAPI[T, ID, REQ]) ToEndpoints ¶
type Endpoint ¶
type FeatureFunc ¶
type FeatureFunc func(*echo.Echo) error
func (FeatureFunc) Apply ¶
func (f FeatureFunc) Apply(app *echo.Echo) error
type FileHeader ¶
type FileHeader struct { File string *multipart.FileHeader }
type FindAPI ¶
type FindAPI[T Record[ID], ID RecordID, REQ BaseRequest] struct { Path string Object Object Bare bool Func func(echo.Context, REQ) (*FindResult[T], error) Middlewares []echo.MiddlewareFunc }
func (FindAPI[T, ID, REQ]) ToEndpoint ¶
type FindResult ¶
type FindResult[T any] struct { Data []T Request any NumRows int PageSize int PageNum int PageTotal int }
func (*FindResult[T]) ToResult ¶ added in v0.1.3
func (fr *FindResult[T]) ToResult(err error) *Result
type ListAPI ¶
type ListAPI[T Record[ID], ID RecordID, REQ BaseRequest] struct { Path string Object Object Bare bool Func func(echo.Context, REQ) ([]T, error) Middlewares []echo.MiddlewareFunc }
func (ListAPI[T, ID, REQ]) ToEndpoint ¶
type MenuItem ¶
type NoRedirectStatic ¶
func (NoRedirectStatic) Apply ¶
func (d NoRedirectStatic) Apply(app *echo.Echo) error
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
func (Object) IsExpanded ¶
func (Object) MatchTagsAny ¶
type Options ¶
type Options struct { DebugMode bool LogSkipper middleware.Skipper ErrorHandler echo.HTTPErrorHandler }
type RequestPage ¶
func (RequestPage) Tuple ¶
func (page RequestPage) Tuple() (int, int)
type Result ¶
type Result struct { // http HttpStatus int ContentType string Headers map[string]string // data Facade any // API & HTML Code any Fields map[string]any Data any Error error View string // contains filtered or unexported fields }
func ResultPage ¶
func (*Result) WithContentType ¶
func (*Result) WithFacade ¶
func (*Result) WithHeader ¶
func (*Result) WithHttpStatus ¶
func (*Result) Write ¶
func (r *Result) Write(ec echo.Context, opts *ResultOptions) error
type ResultOptions ¶
type Routes ¶
type Routes struct { BasePath string Endpoints []any DumpRoute func(method, path string) *ResultOptions }
func (Routes) ExpandEndpoints ¶
type Token ¶
Source Files
¶
- access_control.go
- context.go
- cross_origin.go
- doc.go
- echo.go
- endpoints.go
- errors.go
- feature.go
- feature_access_control.go
- feature_brower_history_router_static.go
- feature_casbin_rbac.go
- feature_inject.go
- feature_menus.go
- feature_noredirect_static.go
- feature_routes.go
- feature_tokens.go
- helper.go
- html_renderer.go
- menu.go
- new.go
- requests.go
- result.go
Click to show internal directories.
Click to hide internal directories.