Documentation ¶
Overview ¶
Package network offers various network tools
Package network offers various network tools ¶
Package network offers various network tools ¶
Package network offers various network tools ¶
Package network offers various network tools ¶
Package network offers various network tools ¶
Package network offers various network tools
Index ¶
- Constants
- type Client
- type DSJSONData
- type DSJSONError
- type DSJSONErrors
- type DSJSONResponse
- type DSJSONSingleResponse
- type DataServ
- func (ds *DataServ) Headers(rw http.ResponseWriter, req *http.Request)
- func (ds *DataServ) Register(route string, jsr DSJSONResponse)
- func (ds *DataServ) RegisterGetFunction(route string, fn DataServFunction)
- func (ds *DataServ) RegisterPostFunction(route string, fn DataServPostFunction)
- func (ds *DataServ) RegisterSingle(route string, jsr DSJSONSingleResponse)
- func (ds *DataServ) RegisterSingleWithPatch(route string, jsr DSJSONSingleResponse, fn DataServPatchFunction)
- func (ds *DataServ) RegisterSingleWithPost(route string, jsr DSJSONSingleResponse, fn DataServPostFunction)
- func (ds *DataServ) RegisterWithPatch(route string, jsr DSJSONResponse, fn DataServPatchFunction)
- func (ds *DataServ) RegisterWithPost(route string, jsr DSJSONResponse, fn DataServPostFunction)
- func (ds *DataServ) Start(host, port string)
- type DataServFunction
- type DataServPatchFunction
- type DataServPostFunction
- type Event
- type EventStream
- type EventsourceClient
- type JSONAPIClient
- func (jac *JSONAPIClient) Delete(url string, header map[string]string, response interface{}) (*JSONError, error)
- func (jac *JSONAPIClient) Post(url string, header map[string]string, data interface{}, response interface{}) (*JSONError, error)
- func (jac *JSONAPIClient) Put(url string, header map[string]string, data interface{}, response interface{}) (*JSONError, error)
- func (jac *JSONAPIClient) Request(url string, header map[string]string, response interface{}) (*JSONError, error)
- type JSONError
- type Server
- type Tokenbucket
Constants ¶
const AppName string = "goBlue/net"
AppName is the name of the application
const FullVersion string = AppName + VersionMajor + "." + VersionMinor + VersionBuild
FullVersion contains the full name and version of this package in a printable string
const VersionBuild string = "s"
VersionBuild is the type of this release. s(table), b(eta), d(evelopment), n(ightly)
const VersionMajor string = "0"
VersionMajor 0 means in development, >1 ensures compatibility with each minor version, but breakes with new major version
const VersionMinor string = "3"
VersionMinor introduces changes that require a new version number. If the major version is 0, they are likely to break compatibility
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a simple network socketclient
type DSJSONData ¶
type DSJSONData struct { ID string `json:"id"` Attributes interface{} `json:"attributes"` Type string `json:"type"` }
DSJSONData has the actual information
type DSJSONError ¶
type DSJSONError struct { Code int `json:"code"` Source string `json:"source"` Detail string `json:"detail"` }
DSJSONError is a single error
type DSJSONErrors ¶
type DSJSONErrors struct {
Errs []DSJSONError `json:"errors"`
}
DSJSONErrors is an error container
type DSJSONResponse ¶
type DSJSONResponse struct {
Data []DSJSONData `json:"data"`
}
DSJSONResponse contains an array of DSJSONData
type DSJSONSingleResponse ¶
type DSJSONSingleResponse struct {
Data DSJSONData `json:"data"`
}
DSJSONSingleResponse contains a single data object
type DataServ ¶
DataServ offers an api to serve function calls and/or json responses to http. Can also wrap a database-like structure to a http-api. Highly optimized for usage with ember-data and is likely to be removed from goBlue
func (*DataServ) Headers ¶
func (ds *DataServ) Headers(rw http.ResponseWriter, req *http.Request)
Headers writes general headers
func (*DataServ) Register ¶
func (ds *DataServ) Register(route string, jsr DSJSONResponse)
Register adds a route with a static response array on any method
func (*DataServ) RegisterGetFunction ¶
func (ds *DataServ) RegisterGetFunction(route string, fn DataServFunction)
RegisterGetFunction adds a route that invokes a function on any method
func (*DataServ) RegisterPostFunction ¶
func (ds *DataServ) RegisterPostFunction(route string, fn DataServPostFunction)
RegisterPostFunction adds a route that invokes a function on POST returning an error on any other method
func (*DataServ) RegisterSingle ¶
func (ds *DataServ) RegisterSingle(route string, jsr DSJSONSingleResponse)
RegisterSingle adds a route with a single static response on any method
func (*DataServ) RegisterSingleWithPatch ¶
func (ds *DataServ) RegisterSingleWithPatch(route string, jsr DSJSONSingleResponse, fn DataServPatchFunction)
RegisterSingleWithPatch adds a route invoking a function on PATCH or returning a single static response on any other method
func (*DataServ) RegisterSingleWithPost ¶
func (ds *DataServ) RegisterSingleWithPost(route string, jsr DSJSONSingleResponse, fn DataServPostFunction)
RegisterSingleWithPost adds a route that invokes a function on POST request with post form input or a single static response on any other method
func (*DataServ) RegisterWithPatch ¶
func (ds *DataServ) RegisterWithPatch(route string, jsr DSJSONResponse, fn DataServPatchFunction)
RegisterWithPatch adds a route invoking a function on PATCH or returning a static response array on any other method
func (*DataServ) RegisterWithPost ¶
func (ds *DataServ) RegisterWithPost(route string, jsr DSJSONResponse, fn DataServPostFunction)
RegisterWithPost adds a route that invokes a function on POST request with post form input or a static response array on any other method
type DataServFunction ¶
type DataServFunction func() error
DataServFunction is a simple function thats called on get request
type DataServPatchFunction ¶
type DataServPatchFunction func(*io.ReadCloser) error
DataServPatchFunction is a function thats called on patch request
type DataServPostFunction ¶
DataServPostFunction is a function thats called on post request taking input
type EventStream ¶
type EventStream struct { EventQueue chan Event // contains filtered or unexported fields }
EventStream contains a channel with events
type EventsourceClient ¶
type EventsourceClient struct {
Stream *EventStream
}
EventsourceClient is a simple Client for Eventsource streams
func (*EventsourceClient) Subscribe ¶
func (ec *EventsourceClient) Subscribe(url string) (*EventStream, error)
Subscribe subscribes to the given Eventsource-Server URL
type JSONAPIClient ¶
type JSONAPIClient struct { }
JSONAPIClient offers a simple json api client interface
func (*JSONAPIClient) Delete ¶
func (jac *JSONAPIClient) Delete(url string, header map[string]string, response interface{}) (*JSONError, error)
Delete calls url with DELETE and sets header. Tries to parse response into any struct, returns jsonerror if request returned one or error on internal errors
func (*JSONAPIClient) Post ¶
func (jac *JSONAPIClient) Post(url string, header map[string]string, data interface{}, response interface{}) (*JSONError, error)
Post calls url with POST with given data and sets header. Tries to parse response into any struct, returns jsonerror if request returned one or error on internal errors
func (*JSONAPIClient) Put ¶
func (jac *JSONAPIClient) Put(url string, header map[string]string, data interface{}, response interface{}) (*JSONError, error)
Put calls url with PUT with given data and sets header. Tries to parse response into any struct, returns jsonerror if request returned one or error on internal errors
func (*JSONAPIClient) Request ¶
func (jac *JSONAPIClient) Request(url string, header map[string]string, response interface{}) (*JSONError, error)
Request calls url with GET and sets header. Tries to parse response into any struct, returns jsonerror if request returned one or error on internal errors
type JSONError ¶
type JSONError struct { Error string `json:"error"` Status int `json:"status"` Message string `json:"message"` }
JSONError contains a simple JSON error message
type Server ¶
type Server struct {
Address, Port string
// contains filtered or unexported fields
}
Server is a simple socketserver. Not doing anything, pretty useless atm. Seriously.
type Tokenbucket ¶
Tokenbucket implements a simple Tokenbucket ratelimiter
func NewTokenbucket ¶
func NewTokenbucket(refill time.Duration, tokens int) *Tokenbucket
NewTokenbucket creates a new Tokenbucket