Documentation ¶
Index ¶
- Constants
- Variables
- func AllCustomerDatasources(w http.ResponseWriter, r *http.Request)
- func CheckAuthKey(w http.ResponseWriter, r *http.Request) bool
- func CheckCustomerForDatasource(w http.ResponseWriter, r *http.Request, customer Customer, ds string) bool
- func DashboardHandler(w http.ResponseWriter, r *http.Request)
- func DeleteLayerHandler(w http.ResponseWriter, r *http.Request)
- func DisableLog()
- func EditFeatureHandler(w http.ResponseWriter, r *http.Request)
- func GetApikeyFromRequest(w http.ResponseWriter, r *http.Request) string
- func IndexHandler(w http.ResponseWriter, r *http.Request)
- func MapHandler(w http.ResponseWriter, r *http.Request)
- func MarshalJsonFromString(w http.ResponseWriter, r *http.Request, data string) ([]byte, error)
- func MarshalJsonFromStruct(w http.ResponseWriter, r *http.Request, data interface{}) ([]byte, error)
- func NewCustomerHandler(w http.ResponseWriter, r *http.Request)
- func NewFeatureHandler(w http.ResponseWriter, r *http.Request)
- func NewLayerHandler(w http.ResponseWriter, r *http.Request)
- func NewTileLayerHandler(w http.ResponseWriter, r *http.Request)
- func PingHandler(w http.ResponseWriter, r *http.Request)
- func ResetLogging()
- func Round(f float64) float64
- func RoundToPrecision(f float64, places int) float64
- func Router() *mux.Router
- func SendJsonResponse(w http.ResponseWriter, r *http.Request, js []byte)
- func ViewFeatureHandler(w http.ResponseWriter, r *http.Request)
- func ViewLayerHandler(w http.ResponseWriter, r *http.Request)
- func ViewLayersHandler(w http.ResponseWriter, r *http.Request)
- type Customer
- type Database
- func (self *Database) CommitQueueLength() int
- func (self *Database) Connect() *bolt.DB
- func (self *Database) CreateTable(conn *bolt.DB, table string) error
- func (self *Database) DeleteLayer(datasource_id string) error
- func (self *Database) EditFeature(datasource_id string, geo_id string, feat *geojson.Feature) error
- func (self *Database) GetCustomer(apikey string) (Customer, error)
- func (self *Database) GetLayer(datasource_id string) (*geojson.FeatureCollection, error)
- func (self *Database) Init() error
- func (self *Database) Insert(table string, key string, value []byte) error
- func (self *Database) InsertCustomer(customer Customer) error
- func (self *Database) InsertFeature(datasource_id string, feat *geojson.Feature) error
- func (self *Database) InsertLayer(datasource_id string, geojs *geojson.FeatureCollection) error
- func (self *Database) NewLayer() (string, error)
- func (self *Database) Select(table string, key string) ([]byte, error)
- func (self *Database) SelectAll(table string) ([]string, error)
- type HttpMessageResponse
- type HttpServer
- type LayerCache
- type PageViewData
- type TcpData
- type TcpMessage
- type TcpServer
- type TileLayer
Constants ¶
const ( TCP_DEFAULT_CONN_HOST = "localhost" TCP_DEFAULT_CONN_PORT = "3333" TCP_DEFAULT_CONN_TYPE = "tcp" )
const HTTP_DEFAULT_PORT = 8080
const (
VERSION string = "1.11.4"
)
Variables ¶
var ( DB Database COMMIT_LOG_FILE string = "commit.log" )
DB application Database
var ( Verbose bool = false ServerLogger seelog.LoggerInterface NetworkLogger seelog.LoggerInterface LogDirectory string = "log" LogLevel string = "trace" )
var (
ActiveTcpClients int
)
Hub contains active websockets for bidirectional communication
var (
SuperuserKey string = utils.NewAPIKey(12)
)
Functions ¶
func AllCustomerDatasources ¶
func AllCustomerDatasources(w http.ResponseWriter, r *http.Request)
Pull all customer datasource pairs Distributed System
func CheckAuthKey ¶
func CheckAuthKey(w http.ResponseWriter, r *http.Request) bool
check request for valid authkey
func CheckCustomerForDatasource ¶
func CheckCustomerForDatasource(w http.ResponseWriter, r *http.Request, customer Customer, ds string) bool
Check customer datasource list
func DashboardHandler ¶
func DashboardHandler(w http.ResponseWriter, r *http.Request)
DashboardHandler returns customer management gui. Allows customers to create and delete both geojson layers and tile baselayers.
func DeleteLayerHandler ¶
func DeleteLayerHandler(w http.ResponseWriter, r *http.Request)
DeleteLayerHandler deletes layer from database and removes it from customer list. @param ds @param apikey @return json
func EditFeatureHandler ¶
func EditFeatureHandler(w http.ResponseWriter, r *http.Request)
EditFeatureHandler finds feature in layer via array index. Edits feature. @param apikey customer id @oaram ds datasource uuid
func GetApikeyFromRequest ¶
func GetApikeyFromRequest(w http.ResponseWriter, r *http.Request) string
Check for apikey in request
func IndexHandler ¶
func IndexHandler(w http.ResponseWriter, r *http.Request)
IndexHandler returns html page containing api docs
func MapHandler ¶
func MapHandler(w http.ResponseWriter, r *http.Request)
MapHandler returns leaflet map view for customer layers @param apikey customer id @return map template
func MarshalJsonFromString ¶
func MarshalJsonFromStruct ¶
func NewCustomerHandler ¶
func NewCustomerHandler(w http.ResponseWriter, r *http.Request)
NewCustomerHandler superuser route to create new api customers/apikeys
func NewFeatureHandler ¶
func NewFeatureHandler(w http.ResponseWriter, r *http.Request)
NewFeatureHandler creates a new feature and adds it to a layer. Layer is then saved to database. All active clients viewing layer are notified of update via websocket hub. @param apikey customer id @oaram ds datasource uuid @return json
func NewLayerHandler ¶
func NewLayerHandler(w http.ResponseWriter, r *http.Request)
NewLayerHandler creates a new geojson layer. Saves layer to database and adds layer to customer @param apikey @return json
func NewTileLayerHandler ¶
func NewTileLayerHandler(w http.ResponseWriter, r *http.Request)
NewLayerHandler creates a new geojson layer. Saves layer to database and adds layer to customer @param apikey @return json
func PingHandler ¶
func PingHandler(w http.ResponseWriter, r *http.Request)
PingHandler provides an api route for server health check
func ResetLogging ¶
func ResetLogging()
func RoundToPrecision ¶
func SendJsonResponse ¶
func SendJsonResponse(w http.ResponseWriter, r *http.Request, js []byte)
Sends http response
func ViewFeatureHandler ¶
func ViewFeatureHandler(w http.ResponseWriter, r *http.Request)
ViewFeatureHandler finds feature in layer via array index. Returns feature geojson. @param apikey customer id @oaram ds datasource uuid @return feature geojson
func ViewLayerHandler ¶
func ViewLayerHandler(w http.ResponseWriter, r *http.Request)
ViewLayerHandler returns geojson of requested layer. Apikey/customer is checked for permissions to requested layer. @param ds @param apikey @return geojson
func ViewLayersHandler ¶
func ViewLayersHandler(w http.ResponseWriter, r *http.Request)
ViewLayersHandler returns json containing customer layers @param apikey customer id @return json
Types ¶
type Customer ¶
type Customer struct { Apikey string `json:"apikey"` Datasources []string `json:"datasources"` TileLayers []TileLayer `json:"tilelayers"` }
Customer structure for database
func GetCustomerFromDatabase ¶
func GetCustomerFromDatabase(w http.ResponseWriter, r *http.Request, apikey string) (Customer, error)
Get customer from database
type Database ¶
type Database struct { File string Cache map[string]*LayerCache Apikeys map[string]Customer Precision int WriteLock bool // contains filtered or unexported fields }
Database strust for application.
func (*Database) CommitQueueLength ¶
CommitQueueLength returns length of database commit_log_queue @returns int
func (*Database) Connect ¶
Connect to bolt database. Returns open database connection. @returns *bolt.DB
func (*Database) CreateTable ¶
CreateTable creates bucket to store data @param table @returns Error
func (*Database) DeleteLayer ¶
DeleteLayer deletes layer from database @param datasource {string} @returns Error
func (*Database) EditFeature ¶
EditFeature Edits feature in layer. Updates layer in Database @param datasource {string} @param geo_id {string} @param feat {Geojson Feature} @returns Error
func (*Database) GetCustomer ¶
GetCustomer returns customer from database @param apikey {string} @returns Customer @returns Error
func (*Database) GetLayer ¶
GetLayer returns layer from database @param datasource {string} @returns Geojson @returns Error
func (*Database) Init ¶
Init creates bolt database if existing one not found. Creates layers and apikey tables. Starts database caching for layers @returns Error
func (*Database) InsertCustomer ¶
InsertCustomer inserts customer into apikeys table @param customer {Customer} @returns Error
func (*Database) InsertFeature ¶
InsertFeature adds feature to layer. Updates layer in Database @param datasource {string} @param feat {Geojson Feature} @returns Error
func (*Database) InsertLayer ¶
InsertLayer inserts layer into database @param datasource {string} @param geojs {Geojson} @returns Error
type HttpMessageResponse ¶
type HttpServer ¶
type HttpServer struct {
Port int
}
func (HttpServer) Start ¶
func (self HttpServer) Start()
type LayerCache ¶
LayerCache keeps track of Database's loaded geojson layers
type PageViewData ¶
MapData for html templates