Documentation
¶
Index ¶
- Variables
- type APIHandler
- type APIHandlerCallbacks
- type Definitions
- type HttpSessionResponse
- type Info
- type Items
- type JsonParametersGetter
- func (p *JsonParametersGetter) Fork(values map[string]interface{}) interface{}
- func (p *JsonParametersGetter) GetBool(path []string, name string) (bool, error)
- func (p *JsonParametersGetter) GetByte(path []string, name string) (uint8, error)
- func (p *JsonParametersGetter) GetFloat32(path []string, name string) (float32, error)
- func (p *JsonParametersGetter) GetFloat64(path []string, name string) (float64, error)
- func (p *JsonParametersGetter) GetInt(path []string, name string) (int, error)
- func (p *JsonParametersGetter) GetInt16(path []string, name string) (int16, error)
- func (p *JsonParametersGetter) GetInt32(path []string, name string) (int32, error)
- func (p *JsonParametersGetter) GetInt64(path []string, name string) (int64, error)
- func (p *JsonParametersGetter) GetInt8(path []string, name string) (int8, error)
- func (p *JsonParametersGetter) GetString(path []string, name string) (string, error)
- func (p *JsonParametersGetter) GetUint(path []string, name string) (uint, error)
- func (p *JsonParametersGetter) GetUint16(path []string, name string) (uint16, error)
- func (p *JsonParametersGetter) GetUint32(path []string, name string) (uint32, error)
- func (p *JsonParametersGetter) GetUint64(path []string, name string) (uint64, error)
- func (p *JsonParametersGetter) GetUint8(path []string, name string) (uint8, error)
- func (p *JsonParametersGetter) IsExists(path []string, name string) bool
- func (p *JsonParametersGetter) Parse() error
- func (p *JsonParametersGetter) TraverseMap(path []string, name string, h func(k string, v interface{}) error) (bool, error)
- func (p *JsonParametersGetter) TraverseSlice(path []string, name string, h func(i int, v interface{}) error) (bool, error)
- type MultipartGetter
- type Operation
- type Parameter
- type ParametersGetter
- func (p *ParametersGetter) Fork(values map[string]interface{}) interface{}
- func (pg *ParametersGetter) GetBool(path []string, name string) (bool, error)
- func (pg *ParametersGetter) GetByte(path []string, name string) (uint8, error)
- func (pg *ParametersGetter) GetFloat32(path []string, name string) (float32, error)
- func (pg *ParametersGetter) GetFloat64(path []string, name string) (float64, error)
- func (pg *ParametersGetter) GetInt(path []string, name string) (int, error)
- func (pg *ParametersGetter) GetInt16(path []string, name string) (int16, error)
- func (pg *ParametersGetter) GetInt32(path []string, name string) (int32, error)
- func (pg *ParametersGetter) GetInt64(path []string, name string) (int64, error)
- func (pg *ParametersGetter) GetInt8(path []string, name string) (int8, error)
- func (pg *ParametersGetter) GetString(path []string, name string) (string, error)
- func (pg *ParametersGetter) GetUint(path []string, name string) (uint, error)
- func (pg *ParametersGetter) GetUint16(path []string, name string) (uint16, error)
- func (pg *ParametersGetter) GetUint32(path []string, name string) (uint32, error)
- func (pg *ParametersGetter) GetUint64(path []string, name string) (uint64, error)
- func (pg *ParametersGetter) GetUint8(path []string, name string) (uint8, error)
- func (pg *ParametersGetter) IsExists(path []string, name string) bool
- func (pg *ParametersGetter) Parse() error
- func (p *ParametersGetter) TraverseMap(path []string, name string, h func(k string, v interface{}) error) (bool, error)
- func (p *ParametersGetter) TraverseSlice(path []string, name string, h func(i int, v interface{}) error) (bool, error)
- type PathItem
- type Properties
- type Response
- type Responses
- type Schema
- type SecurityDefinitions
- type SecurityRequirement
- type SecurityScheme
- type Swagger
- type SwaggerJSONCallbacks
- type SwaggerJSONHandler
- type Tag
Constants ¶
This section is empty.
Variables ¶
View Source
var PrintDebug = false
Functions ¶
This section is empty.
Types ¶
type APIHandler ¶
type APIHandler struct {
// contains filtered or unexported fields
}
func NewAPIHandler ¶
func NewAPIHandler(hm *gorpc.HandlersManager, cache cache.ICache, callbacks APIHandlerCallbacks) *APIHandler
func (*APIHandler) ServeHTTP ¶
func (h *APIHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*APIHandler) SetTimeout ¶
func (h *APIHandler) SetTimeout(timeout time.Duration) *APIHandler
type APIHandlerCallbacks ¶
type APIHandlerCallbacks struct { OnInitCtx func(ctx context.Context, req *http.Request) context.Context OnError func(ctx context.Context, w http.ResponseWriter, req *http.Request, resp interface{}, err *gorpc.CallHandlerError) OnPanic func(ctx context.Context, w http.ResponseWriter, r interface{}, trace []byte, req *http.Request) OnStartServing func(ctx context.Context, req *http.Request) OnEndServing func(ctx context.Context, req *http.Request, startTime time.Time) OnBeforeWriteResponse func(ctx context.Context, w http.ResponseWriter) OnSuccess func(ctx context.Context, req *http.Request, handlerResponse interface{}, startTime time.Time) On304 func(ctx context.Context, req *http.Request) On404 func(ctx context.Context, req *http.Request) OnCacheHit func(ctx context.Context, entry *cache.CacheEntry) OnCacheMiss func(ctx context.Context) GetCacheKey func(ctx context.Context, req *http.Request, params interface{}) []byte }
type Definitions ¶
type Definitions map[string]interface{}
type HttpSessionResponse ¶
type HttpSessionResponse struct { Result string `json:"result"` Data interface{} `json:"data"` Error string `json:"error"` Debug *debug.Debug `json:"debug,omitempty"` }
func (HttpSessionResponse) MarshalEasyJSON ¶
func (v HttpSessionResponse) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (HttpSessionResponse) MarshalJSON ¶
func (v HttpSessionResponse) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*HttpSessionResponse) UnmarshalEasyJSON ¶
func (v *HttpSessionResponse) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*HttpSessionResponse) UnmarshalJSON ¶
func (v *HttpSessionResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type JsonParametersGetter ¶
type JsonParametersGetter struct { Req io.ReadCloser MaxFormSize int64 // contains filtered or unexported fields }
func (*JsonParametersGetter) Fork ¶
func (p *JsonParametersGetter) Fork(values map[string]interface{}) interface{}
func (*JsonParametersGetter) GetBool ¶
func (p *JsonParametersGetter) GetBool(path []string, name string) (bool, error)
func (*JsonParametersGetter) GetByte ¶
func (p *JsonParametersGetter) GetByte(path []string, name string) (uint8, error)
func (*JsonParametersGetter) GetFloat32 ¶
func (p *JsonParametersGetter) GetFloat32(path []string, name string) (float32, error)
func (*JsonParametersGetter) GetFloat64 ¶
func (p *JsonParametersGetter) GetFloat64(path []string, name string) (float64, error)
func (*JsonParametersGetter) GetInt ¶
func (p *JsonParametersGetter) GetInt(path []string, name string) (int, error)
func (*JsonParametersGetter) GetInt16 ¶
func (p *JsonParametersGetter) GetInt16(path []string, name string) (int16, error)
func (*JsonParametersGetter) GetInt32 ¶
func (p *JsonParametersGetter) GetInt32(path []string, name string) (int32, error)
func (*JsonParametersGetter) GetInt64 ¶
func (p *JsonParametersGetter) GetInt64(path []string, name string) (int64, error)
func (*JsonParametersGetter) GetInt8 ¶
func (p *JsonParametersGetter) GetInt8(path []string, name string) (int8, error)
func (*JsonParametersGetter) GetString ¶
func (p *JsonParametersGetter) GetString(path []string, name string) (string, error)
func (*JsonParametersGetter) GetUint ¶
func (p *JsonParametersGetter) GetUint(path []string, name string) (uint, error)
func (*JsonParametersGetter) GetUint16 ¶
func (p *JsonParametersGetter) GetUint16(path []string, name string) (uint16, error)
func (*JsonParametersGetter) GetUint32 ¶
func (p *JsonParametersGetter) GetUint32(path []string, name string) (uint32, error)
func (*JsonParametersGetter) GetUint64 ¶
func (p *JsonParametersGetter) GetUint64(path []string, name string) (uint64, error)
func (*JsonParametersGetter) GetUint8 ¶
func (p *JsonParametersGetter) GetUint8(path []string, name string) (uint8, error)
func (*JsonParametersGetter) IsExists ¶
func (p *JsonParametersGetter) IsExists(path []string, name string) bool
func (*JsonParametersGetter) Parse ¶
func (p *JsonParametersGetter) Parse() error
func (*JsonParametersGetter) TraverseMap ¶
func (*JsonParametersGetter) TraverseSlice ¶
type MultipartGetter ¶
type MultipartGetter struct {
ParametersGetter
}
func NewMultipartGetter ¶
func NewMultipartGetter(req *http.Request) (*MultipartGetter, error)
func (*MultipartGetter) Parse ¶
func (g *MultipartGetter) Parse() error
Add upload files to Params like a string params["{inputName}"] = string(file) params["filename_{inputName}"] = string(filename)
Example:
type MyData struct { File string `key:"my_file"` Filename string `key:"filename_my_file"` }
type Operation ¶
type Operation struct { Tags []string `json:"tags,omitempty"` Summary string `json:"summary"` Description string `json:"description"` Consumes []string `json:"consumes,omitempty"` Produces []string `json:"produces,omitempty"` Parameters []*Parameter `json:"parameters,omitempty"` Responses Responses `json:"responses,omitempty"` Security []*SecurityRequirement `json:"security,omitempty"` ExtraData interface{} `json:"-"` }
type ParametersGetter ¶
func (*ParametersGetter) Fork ¶
func (p *ParametersGetter) Fork(values map[string]interface{}) interface{}
func (*ParametersGetter) GetBool ¶
func (pg *ParametersGetter) GetBool(path []string, name string) (bool, error)
func (*ParametersGetter) GetByte ¶
func (pg *ParametersGetter) GetByte(path []string, name string) (uint8, error)
func (*ParametersGetter) GetFloat32 ¶
func (pg *ParametersGetter) GetFloat32(path []string, name string) (float32, error)
func (*ParametersGetter) GetFloat64 ¶
func (pg *ParametersGetter) GetFloat64(path []string, name string) (float64, error)
func (*ParametersGetter) GetInt ¶
func (pg *ParametersGetter) GetInt(path []string, name string) (int, error)
func (*ParametersGetter) GetInt16 ¶
func (pg *ParametersGetter) GetInt16(path []string, name string) (int16, error)
func (*ParametersGetter) GetInt32 ¶
func (pg *ParametersGetter) GetInt32(path []string, name string) (int32, error)
func (*ParametersGetter) GetInt64 ¶
func (pg *ParametersGetter) GetInt64(path []string, name string) (int64, error)
func (*ParametersGetter) GetInt8 ¶
func (pg *ParametersGetter) GetInt8(path []string, name string) (int8, error)
func (*ParametersGetter) GetString ¶
func (pg *ParametersGetter) GetString(path []string, name string) (string, error)
func (*ParametersGetter) GetUint ¶
func (pg *ParametersGetter) GetUint(path []string, name string) (uint, error)
func (*ParametersGetter) GetUint16 ¶
func (pg *ParametersGetter) GetUint16(path []string, name string) (uint16, error)
func (*ParametersGetter) GetUint32 ¶
func (pg *ParametersGetter) GetUint32(path []string, name string) (uint32, error)
func (*ParametersGetter) GetUint64 ¶
func (pg *ParametersGetter) GetUint64(path []string, name string) (uint64, error)
func (*ParametersGetter) GetUint8 ¶
func (pg *ParametersGetter) GetUint8(path []string, name string) (uint8, error)
func (*ParametersGetter) IsExists ¶
func (pg *ParametersGetter) IsExists(path []string, name string) bool
func (*ParametersGetter) Parse ¶
func (pg *ParametersGetter) Parse() error
func (*ParametersGetter) TraverseMap ¶
func (*ParametersGetter) TraverseSlice ¶
type Properties ¶
type Schema ¶
type Schema struct { Ref string `json:"$ref,omitempty"` Type string `json:"type,omitempty"` Description string `json:"description,omitempty"` Required []string `json:"required,omitempty"` Items *Items `json:"items,omitempty"` Properties Properties `json:"properties,omitempty"` AdditionalProperties *Schema `json:"additionalProperties,omitempty"` }
type SecurityDefinitions ¶
type SecurityDefinitions map[string]*SecurityScheme
SecurityDefinitions security definitions
type SecurityRequirement ¶
SecurityRequirement security requirement
type SecurityScheme ¶
type SecurityScheme struct { Type string `json:"type"` Description string `json:"description,omitempty"` Name string `json:"name"` In string `json:"in"` Xtensions []string `json:"x-extensions,omitempty"` }
SecurityScheme security scheme
type Swagger ¶
type Swagger struct { SpecVersion string `json:"swagger"` Info Info `json:"info"` BasePath string `json:"basePath"` Host string `json:"host,omitempty"` Schemes []string `json:"schemes,omitempty"` Consumes []string `json:"consumes,omitempty"` Produces []string `json:"produces,omitempty"` Paths map[string]PathItem `json:"paths"` Tags []Tag `json:"tags,omitempty"` Definitions Definitions `json:"definitions,omitempty"` SecurityDefinitions SecurityDefinitions `json:"securityDefinitions,omitempty"` }
func GenerateSwaggerJSON ¶
func GenerateSwaggerJSON(hm *gorpc.HandlersManager, host string, callbacks SwaggerJSONCallbacks) (*Swagger, error)
type SwaggerJSONCallbacks ¶
type SwaggerJSONCallbacks struct { OnPrepareBaseInfoJSON func(info *Info) OnPrepareHandlerJSON func(path string, data *Operation) Process func(swagger *Swagger) TagName func(path string) string }
SwaggerJSONCallbacks is struct for callbacks describing
type SwaggerJSONHandler ¶
type SwaggerJSONHandler struct {
// contains filtered or unexported fields
}
func NewSwaggerJSONHandler ¶
func NewSwaggerJSONHandler(hm *gorpc.HandlersManager, apiPort uint16, callbacks SwaggerJSONCallbacks) *SwaggerJSONHandler
func (*SwaggerJSONHandler) ServeHTTP ¶
func (h *SwaggerJSONHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.