def

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Content_Type        = "Content-Type"
	Content_Encoding    = "Content-Encoding"
	Content_JSON        = "application/json"
	CONTENT_STREAM      = "application/octet-stream"
	CONTENT_HTML        = "text/html"
	HEAD_CONST          = "_API_HEADER_TYPE_"
	CONTENT_DISPOSITION = "Content-Disposition"
)
View Source
const (
	Handler_API     = HandlerOrder(100)
	Handler_GZIP    = HandlerOrder(98)
	Handler_STATIC  = HandlerOrder(99)
	Handler_NOTFIND = HandlerOrder(1000)
)

HandlerOrder 0-100 system 100-1000 user

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Mapper(param *ParamWarp) reflect.Value
	Register() []reflect.Type
}

type AppendHeader

type AppendHeader interface {
	Append(header ReadHeader) map[string]string
}

AppendHeader used in retType

type Caller

type Caller interface {
	// CallerTrace
	// Call request ==> object
	Call(f *Entry, req *Request) interface{}
}

type CallerTrace added in v0.1.0

type CallerTrace interface {
	Before() bool
	After()
}

type Content

type Content struct {
	ContentType string
	Bytes       []byte
}

type ContentType

type ContentType interface {
	ContentType() string
}

ContentType used in retType

type Context added in v0.1.0

type Context struct {
	Match     Match
	Pool      *MethodsPools
	Caller    Caller
	Serialize Serialize
}
var DefaultContext *Context
type Cookie interface {
	SetCookie(cookie *http.Cookie)
	Cookie(name string) (*http.Cookie, error)
}

type Empty added in v0.1.0

type Empty string

Empty

type Entry

type Entry struct {
	Url        string
	Group      string
	HttpMethod string
	Fn         interface{}
	Ids        utils.Map[string, string]
}

type Error

type Error struct {
	ErrorMessage string `json:"error"`
	Code         int    `json:"code"`
}

func NewError

func NewError(string2 string) Error

func NewErrorCode

func NewErrorCode(string2 string, code int) Error

func (Error) Error

func (e Error) Error() string

type Flusher

type Flusher interface {
	// Flush sends any buffered data to the client.
	Flush()
}

type HandlerOrder added in v0.1.0

type HandlerOrder uint
type Header interface {
	Cookie
	ReadHeader
	WriteHeader
}

Header used in param eg. *

 GET(func(a def.Header) interface{} {
		return a.Values("Accept-Encoding")
 }, "/h")

type HttpMethod added in v0.1.0

type HttpMethod func(f any, url string) Option

type HttpStatus

type HttpStatus interface {
	Code() int
}

type Int added in v0.1.0

type Int[T any] struct {
	V int
	// contains filtered or unexported fields
}

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (Int[T]) Int added in v0.1.0

func (i Int[T]) Int() int

type Int16 added in v0.1.0

type Int16[T any] struct {
	V int16
	// contains filtered or unexported fields
}

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (Int16[T]) Int16 added in v0.1.0

func (i Int16[T]) Int16() int16

type Int16Req

type Int16Req Int16[int16]

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (Int16Req) Int16

func (i Int16Req) Int16() int16

type Int32 added in v0.1.0

type Int32[T any] struct {
	V int32
	// contains filtered or unexported fields
}

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

type Int32Req

type Int32Req Int32[int32]

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

type Int64 added in v0.1.0

type Int64[T any] struct {
	V int64
	// contains filtered or unexported fields
}

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (Int64[T]) Int64 added in v0.1.0

func (i Int64[T]) Int64() int64

type Int64Req

type Int64Req Int64[int64]

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (Int64Req) Int64 added in v0.0.4

func (i Int64Req) Int64() int64

type Int8 added in v0.1.0

type Int8[T any] struct {
	V int8
	// contains filtered or unexported fields
}

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (Int8[T]) Int32 added in v0.1.0

func (i Int8[T]) Int32() int32

func (Int8[T]) Int8 added in v0.1.0

func (i Int8[T]) Int8() int8

type Int8Req

type Int8Req Int8[int8]

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (Int8Req) Int32

func (i Int8Req) Int32() int32

func (Int8Req) Int8

func (i Int8Req) Int8() int8

type IntReq

type IntReq Int[int]

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (IntReq) Int

func (i IntReq) Int() int

type Match

type Match interface {
	Match(url *url.URL) *Entry
	Add(key string, data interface{})
}

type MethodInfo

type MethodInfo struct {
	Pkg        string                    `json:"pkg"`
	Receive    string                    `json:"receive"`
	Method     *Entry                    `json:"-"`
	MethodName string                    `json:"method_name"`
	Param      map[string]dwarf.ArgsMeta `json:"param"`
	Middleware []MiddleWare
	KV         sync.Map
}

type MethodsPools added in v0.1.0

type MethodsPools struct {
	utils.Map[string, *MethodInfo]
}

func (*MethodsPools) FuncInfo added in v0.1.0

func (m *MethodsPools) FuncInfo(fn any) *MethodInfo

type MiddleWare added in v0.1.0

type MiddleWare func(req *http.Request) (ret any)

MiddleWare If ret == nil The next MiddleWare will continue if ret != nil Ret will be used as the result

type Option added in v0.1.0

type Option interface {
	SetContext(ctx *Context) Option
	SetMethod(md *MethodInfo) Option
	StoreKV(key string, v any)
	Swagger(opsFn func(swagger SwaggerOps)) Option
	SetMiddleware(m ...MiddleWare) Option
	Path() string
	Method() string
}

type Param

type Param struct {
	Order int    `json:"order"`
	Name  string `json:"name"`
}

type ParamWarp

type ParamWarp struct {
	Request
	PTyp   reflect.Type
	PValue string
	Path   string
	PName  string
}

type ReadHeader

type ReadHeader interface {
	Get(key string) string
	Values(key string) []string
}

type Request added in v0.1.0

type Request struct {
	*http.Request
	// contains filtered or unexported fields
}

func WithRequest added in v0.1.0

func WithRequest(rw http.ResponseWriter, req *http.Request) *Request

func (*Request) ResponseWriter added in v0.1.0

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

type RetAdapter

type RetAdapter interface {
	ContentType
	Return() io.Reader
	Register() []reflect.Type
}

type Serialize

type Serialize interface {
	Encode(interface{}) *Content
	// Decode interface{} is out
	Decode([]byte, interface{}) error
}

type String added in v0.1.0

type String[T any] struct {
	V string
	// contains filtered or unexported fields
}

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (String[T]) String added in v0.1.0

func (i String[T]) String() string

type StringReq

type StringReq String[string]

require param *

  //b is require
  GET(func(a int, b def.StringReq) {
		fmt.Println(a, b)
   }, "/require")

func (StringReq) String

func (i StringReq) String() string

type SwaggerOps added in v0.1.0

type SwaggerOps interface {
	SwaggerSecurity
	SetSummary(title string)
	SetTag(tag string)
	SetDescription(description string)
	SetParameterDescription(name, description string)
}

type SwaggerSecurity added in v0.1.0

type SwaggerSecurity interface {
	SecuritCookie(name string, cookieName string)
	SecuritApiHeader(name string, headerName string)
	SecuritJwt(name string)
}

type WriteHeader

type WriteHeader interface {
	Add(key, value string)
}

Jump to

Keyboard shortcuts

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