ajkApi

package
v0.0.0-...-05317bf Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2015 License: MIT Imports: 16 Imported by: 0

README

ajkapi

  • a rpc system try to ease web and client develop.
  • easy to document every api in the system

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdditionHttpHandler []HttpHandlerConfig

Functions

func ContextGetSession

func ContextGetSession(c kmgContext.Context) *sessionStore.Session

func ContextSetSession

func ContextSetSession(c kmgContext.Context, sess *sessionStore.Session)

func HttpApiDeflateCompressFilter

func HttpApiDeflateCompressFilter(c *HttpApiContext, fc []HttpApiFilter)

func RunGoHttpApiServerCmd

func RunGoHttpApiServerCmd()

Types

type ApiFuncArgumentError

type ApiFuncArgumentError struct {
	Reason  string
	ApiName string
}

func (*ApiFuncArgumentError) Error

func (err *ApiFuncArgumentError) Error() string

type ApiFuncMeta

type ApiFuncMeta struct {
	IsMethod     bool
	Func         reflect.Value
	AttachObject reflect.Value // the object method attached
	MethodName   string
}

type ApiFuncNotFoundError

type ApiFuncNotFoundError struct {
	Reason  string
	ApiName string
}

func (*ApiFuncNotFoundError) Error

func (err *ApiFuncNotFoundError) Error() string

type ApiManagerInterface

type ApiManagerInterface interface {
	/*
		must pass a session object
		input and output can be
		*struct{xxx}
		map[string]interface
	*/
	RpcCall(session *sessionStore.Session, name string, caller func(*ApiFuncMeta) error) error
}

ApiFunc must be something like(follow golang rpc protocol)(can not reflect parameter name)

	1.func Add(apiInput *ReqisterRequest,apiOutput *RegisterResponse)(error){
   2.func Add(apiInput *ReqisterRequest)(error){
   3.func Add()(error)
   4.func Add()

type GoHttpApiServerCommand

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

start a golang http api server

type HttpApiContext

type HttpApiContext struct {
	Request        *http.Request
	ResponseWriter http.ResponseWriter
	ApiName        string
}

type HttpApiFilter

type HttpApiFilter func(c *HttpApiContext, fc []HttpApiFilter)

type HttpApiFilterManager

type HttpApiFilterManager struct {
	Filters []HttpApiFilter
}

func (*HttpApiFilterManager) ServeHTTP

func (m *HttpApiFilterManager) ServeHTTP(w http.ResponseWriter, req *http.Request)

type HttpHandlerConfig

type HttpHandlerConfig struct {
	Path    string
	Handler http.Handler
}

type JsonHttpHandler

type JsonHttpHandler struct {
	ApiManager          ApiManagerInterface
	SessionStoreManager *sessionStore.Manager
}

func (*JsonHttpHandler) Filter

func (handler *JsonHttpHandler) Filter(c *HttpApiContext, _ []HttpApiFilter)

func (*JsonHttpHandler) ServeHTTP

func (handler *JsonHttpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type JsonHttpInput

type JsonHttpInput struct {
	Name string
	Guid string //
	Data interface{}
}

type JsonHttpOutput

type JsonHttpOutput struct {
	Err  string
	Guid string // "" as not set guid to peer
	Data interface{}
}

type RegisterApiManager

type RegisterApiManager map[string]func(c kmgContext.Context) interface{}

api注册方式

var DefaultApiManager RegisterApiManager = NewApiManager()

func NewApiManager

func NewApiManager() RegisterApiManager

container service + method -> api the api name will be "serviceName.methodName"

func (RegisterApiManager) RpcCall

func (manager RegisterApiManager) RpcCall(
	session *sessionStore.Session,
	name string,
	caller func(*ApiFuncMeta) error,
) error

type SessionIdContainer

type SessionIdContainer struct {
	SessionId string
}

Jump to

Keyboard shortcuts

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