Documentation
¶
Index ¶
- Constants
- Variables
- func ErrInvalidGroupPointer(iface interface{}) error
- func GetEnity(ctx context.Context, provider, enityName string) (interface{}, error)
- func Registrate(ctx context.Context) context.Context
- func RegistrateEnity(ctx context.Context, provider, enityName string, options interface{}) (context.Context, error)
- func RegistrateProvider(ctx context.Context, name string, p Provider) (context.Context, error)
- type ErrorAnsw
- func BadRequest(err error) ErrorAnsw
- func CreateFailed(err error) ErrorAnsw
- func Forbidden(err error) ErrorAnsw
- func HasExpired(err error) ErrorAnsw
- func InternalServerError(err error) ErrorAnsw
- func NewErrorAnsw(statusCode int, code string, err error) ErrorAnsw
- func NotDeleted(err error) ErrorAnsw
- func NotFound(err error) ErrorAnsw
- func NotUpdated(err error) ErrorAnsw
- func Unauthorized(err error) ErrorAnsw
- type ErrorAnswBody
- type HTTPServers
- func (https *HTTPServers) CreateAPIVersionGroup(providerName, serverName, apiVersion string, middlewares ...interface{}) error
- func (https *HTTPServers) CreateEnity(providerName, serverName string, options interface{}) error
- func (https *HTTPServers) GetAPIVersionGroup(providerName, serverName, apiVersion string) (interface{}, error)
- func (https *HTTPServers) GetEnity(providerName, serverName string) (interface{}, error)
- func (https *HTTPServers) GetProvider(providerName string) (Provider, error)
- func (https *HTTPServers) RegisterEndpoint(providerName, serverName, method, endpoint string, handler http.Handler, ...) error
- type MiddleWareFunc
- type Provider
- type ResultAnsw
Constants ¶
View Source
const (
ProvidersName = "httpsrv"
)
Variables ¶
View Source
var ( ErrEmptyHTTPServers = errors.New("empty http(s) servers") ErrEmptyServerName = errors.New("empty server name is not allowed") ErrServerNotFound = errors.New("requested server wasn't created yet") ErrServerNameMissing = errors.New("server's name is empty") ErrGroupNotFound = errors.New("requested API version group wasn't found") ErrBindAddressMissing = errors.New("bind address wasn't specified") ErrServerAlreadyStarted = errors.New("server already started") ErrEmptyHTTPHandler = errors.New("empty http handler") ErrUnknownHTTPMethod = errors.New("unknown http method") ErrServerNotUp = errors.New("http server isn't up after 10 seconds") )
Functions ¶
func ErrInvalidGroupPointer ¶
func ErrInvalidGroupPointer(iface interface{}) error
func RegistrateEnity ¶
Types ¶
type ErrorAnsw ¶
type ErrorAnsw struct {
Body ErrorAnswBody `json:"error"`
}
func InternalServerError ¶
InternalServerError return err 500
func NewErrorAnsw ¶
NewErrorAnsw create new ErrorAnsw and fills it withcode, statuscode, details
type ErrorAnswBody ¶
type HTTPServers ¶
type HTTPServers struct {
*providers.BaseProviders
}
HTTPServers structure controls all HTTP servers for gowork.
func Get ¶
func Get(ctx context.Context) *HTTPServers
func NewHTTPServers ¶
func NewHTTPServers(ctx context.Context) *HTTPServers
func (*HTTPServers) CreateAPIVersionGroup ¶
func (https *HTTPServers) CreateAPIVersionGroup(providerName, serverName, apiVersion string, middlewares ...interface{}) error
CreateAPIVersionGroup creates new API version group using designated provider.
func (*HTTPServers) CreateEnity ¶
func (https *HTTPServers) CreateEnity(providerName, serverName string, options interface{}) error
CreateEnity creates new HTTP server using designated provider.
func (*HTTPServers) GetAPIVersionGroup ¶
func (https *HTTPServers) GetAPIVersionGroup(providerName, serverName, apiVersion string) (interface{}, error)
GetAPIVersionGroup returns HTTP server routing group using designated provider.
func (*HTTPServers) GetEnity ¶
func (https *HTTPServers) GetEnity(providerName, serverName string) (interface{}, error)
GetEnity returns HTTP server controlling structure from designated provider.
func (*HTTPServers) GetProvider ¶
func (https *HTTPServers) GetProvider(providerName string) (Provider, error)
GetProvider returns provider. Returns error if provider isn't registered.
func (*HTTPServers) RegisterEndpoint ¶
func (https *HTTPServers) RegisterEndpoint( providerName, serverName, method, endpoint string, handler http.Handler, m ...MiddleWareFunc) error
RegisterEndpoint register endpoint on selected HTTP server.
type Provider ¶
type Provider interface { provider.IProvider provider.IEnityManager // CreateAPIVersionGroup should be responsible for creating // routes grouping for specified API version. Version should be // a string without leading "v" or "version" or anything like that. // Provider should append "v" automatically. // Passed group should be a pointer to needed structure that might be // provided by HTTP server provider. Provider should not attempt to // replace pointer if nil is passed. Provider should check if passed // group is a pointer to valid structure. // It is up to provider to cast options and middlewares to needed type. CreateAPIVersionGroup(serverName string, apiVersion string, middlewares ...interface{}) error // GetAPIVersionGroup should return handler for passed version // API. Version should be a string without leading "v" or "version" // or anything like that. Provider should append "v" automatically. // Passed group should be a pointer to needed structure that might be // provided by HTTP server provider. Provider should not attempt to // replace pointer if nil is passed. Provider should check if passed // group is a pointer to valid structure. GetAPIVersionGroup(serverName string, apiVersion string) (interface{}, error) // Register endpoint on server RegisterEndpoint(serverName, method, endpoint string, handler http.Handler, middleware ...MiddleWareFunc) error }
Provider is an interface every provider should follow.
type ResultAnsw ¶
type ResultAnsw struct {
Body interface{} `json:"result"`
}
Click to show internal directories.
Click to hide internal directories.