quark

package module
v0.0.0-...-a4db070 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: MIT Imports: 13 Imported by: 0

README

quark

Documentation

Index

Constants

View Source
const (
	ROOT_SERVICE_NAME = "root"
)

Variables

View Source
var (
	StringType = reflect.TypeOf(String(""))
	IntType    = reflect.TypeOf(Int(0))
	NumberType = reflect.TypeOf(Number(0))
)

Functions

func IsUrlType

func IsUrlType(t reflect.Type) bool

func Js

func Js(x interface{}) string

func MakeSlice

func MakeSlice(x interface{}, len int)

x must be pointer of slice

func PathElementChoices

func PathElementChoices(elem string) (results []string)

func Resize

func Resize(x interface{}, len int)

Types

type Api

type Api struct {
	Method string // blank means any, or http.MethodXXX

	Path string

	Request       reflect.Type
	Response      reflect.Type
	ReflectMethod reflect.Method
	PathVars      []util.PathVar // key: path element pos, value: i/s/f.{varname}
	QueryVars     map[string]int // key: var name, value: pos in req struct
	// contains filtered or unexported fields
}

func (*Api) Run

func (a *Api) Run(w http.ResponseWriter, r *http.Request, pathElems []string)

func (*Api) Service

func (api *Api) Service() *Service

func (*Api) SwaggerOperations

func (a *Api) SwaggerOperations() *spec.Operation

func (*Api) SwaggerPathItem

func (a *Api) SwaggerPathItem() *spec.PathItem

type AuthenticateFunc

type AuthenticateFunc func(c *Console) bool

type Console

type Console struct {
	// contains filtered or unexported fields
}

func NewConsole

func NewConsole(w http.ResponseWriter, r *http.Request, body []byte) *Console

func (Console) Body

func (c Console) Body() []byte

func (Console) Context

func (c Console) Context() interface{}

func (Console) Halt

func (c Console) Halt(status int, e interface{})

func (Console) Request

func (c Console) Request() *http.Request

func (Console) ResponseWriter

func (c Console) ResponseWriter() http.ResponseWriter

func (*Console) SaveContext

func (c *Console) SaveContext(a interface{})

type Int

type Int int

func (Int) V

func (i Int) V() int

type JsonMarshalFunc

type JsonMarshalFunc func(x interface{}) ([]byte, error)

type JsonUnmarshalFunc

type JsonUnmarshalFunc func(b []byte, x interface{}) error

type Number

type Number float64

func (Number) V

func (n Number) V() float64

type Option

type Option struct {
	Authenticate AuthenticateFunc
	PathPrefix   []string
}

type Quark

type Quark struct {
	Marshal   JsonMarshalFunc
	Unmarshal JsonUnmarshalFunc
	Services  []Service
	// contains filtered or unexported fields
}

func NewQuark

func NewQuark() *Quark

func (*Quark) RegisterService

func (q *Quark) RegisterService(instances ...interface{})

func (*Quark) ServeHTTP

func (q *Quark) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Quark) SwaggerSchemaFromStruct

func (q *Quark) SwaggerSchemaFromStruct(t reflect.Type, omit_url_parameters bool) (schema spec.Schema)

func (*Quark) SwaggerSchemaFromType

func (q *Quark) SwaggerSchemaFromType(t reflect.Type, omit_url_parameters bool) (schema spec.Schema)

func (*Quark) SwaggerSpec

func (q *Quark) SwaggerSpec() *spec.Swagger

func (*Quark) WithAuthenticate

func (q *Quark) WithAuthenticate(f AuthenticateFunc)

func (*Quark) WithPathPrefix

func (q *Quark) WithPathPrefix(p []string)

type Service

type Service struct {
	Name        string
	ServiceType reflect.Type
	Apis        []Api
	// contains filtered or unexported fields
}

func (Service) DumpPaths

func (s Service) DumpPaths()

func (*Service) Quark

func (s *Service) Quark() *Quark

func (*Service) Route

func (s *Service) Route(w http.ResponseWriter, r *http.Request, pathElems []string) (accepted bool)

type String

type String string

func (String) V

func (s String) V() string

type TypeAndFormat

type TypeAndFormat struct {
	T string
	F string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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