Documentation ¶
Overview ¶
working code for APIs
auth logic
callback router
client information
resources
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { BaseURL string Resources map[string]*RestResource // names for the resources (queries) DefaultRouter *CBRouter // pointer to the CBRouter (dynamic, if a resource have it) Client *Client // Client library (wrapper HTTP client) }
func (*API) AddResource ¶
func (api *API) AddResource(name string, res *RestResource)
adding resources
func (*API) ResourceNames ¶
func (*API) SetAuth ¶
func (api *API) SetAuth(auth Authentication)
setting up to the client (if needed)
type AuthToken ¶
type AuthToken struct {
Token string // random string
}
func NewAuthToken ¶
func (*AuthToken) AuthorizationHeader ¶
type Authentication ¶
type Authentication interface {
AuthorizationHeader() string // basic <base64-encoded- string>
}
type CBRouter ¶
type CBRouter struct { Routers map[int]RouterFunc // int = statusCode <> function execution DefaultRouter RouterFunc }
func (*CBRouter) RegisterFunc ¶
func (r *CBRouter) RegisterFunc(status int, fn RouterFunc)
type Client ¶
type Client struct { Client *http.Client AuthInfo Authentication // interface }
func (*Client) ProcessRequest ¶
func (c *Client) ProcessRequest(baseURL string, res *RestResource, params map[string]string, payload interface{}) error
processing request
func (*Client) SetAuth ¶
func (c *Client) SetAuth(auth Authentication)
type RestResource ¶
type RestResource struct { Endpoint string // URI Method string // HTTP verb Router *CBRouter // for dynamic resources (re-usage instead of recreation) }
func NewResource ¶
func NewResource(endpoint, method string, router *CBRouter) *RestResource
func (*RestResource) RenderEndpoint ¶
func (r *RestResource) RenderEndpoint(params map[string]string) string
returning the endpoint string
type RouterFunc ¶
Click to show internal directories.
Click to hide internal directories.