Documentation ¶
Overview ¶
* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *
* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *
* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *
* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *
* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *
* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *
* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *
Index ¶
- Constants
- Variables
- func Authenticator(www wwwtemplatebookmark, apifunc webcore.APIHandler, db *connectordb.Database) http.HandlerFunc
- func Device(o *authoperator.AuthOperator, writer http.ResponseWriter, ...) (int, string)
- func Index(o *authoperator.AuthOperator, writer http.ResponseWriter, ...) (int, string)
- func JoinHandleGET(writer http.ResponseWriter, request *http.Request)
- func JoinHandlePOST(writer http.ResponseWriter, request *http.Request)
- func LoadFiles() error
- func Login(o *authoperator.AuthOperator, writer http.ResponseWriter, ...) (int, string)
- func LogoutHandler(writer http.ResponseWriter, request *http.Request)
- func NotFoundHandler(writer http.ResponseWriter, request *http.Request)
- func Router(db *connectordb.Database, r *mux.Router) (*mux.Router, error)
- func Stream(o *authoperator.AuthOperator, writer http.ResponseWriter, ...) (int, string)
- func User(o *authoperator.AuthOperator, writer http.ResponseWriter, ...) (int, string)
- func VerifyCaptcha(response string) (bool, error)
- func WriteError(logger *log.Entry, writer http.ResponseWriter, status int, err error, ...) (int, string)
- type JoinStream
- type Joiner
- type TemplateData
- func (td *TemplateData) DataURIToAttr(uri string) template.HTMLAttr
- func (t *TemplateData) ReadDevices() (out []*users.Device, err error)
- func (t *TemplateData) ReadMyDevices() (out []*users.Device, err error)
- func (t *TemplateData) ReadMyStreams() (out []*users.Stream, err error)
- func (t *TemplateData) ReadStreams() (out []*users.Stream, err error)
- func (t *TemplateData) ReadUsers() (out []*users.User, err error)
Constants ¶
const ( //The prefix to use for the paths in web server WWWPrefix = "www" AppPrefix = "app" )
Variables ¶
var ( // WWWPath is the path to the not-logged-in website files WWWPath string // AppPath is the path to the logged-in user website files AppPath string // These are the pre-loaded templates for non-logged in users WWWTemplate *hot.Template // These are the pre-loaded templates for logged in users AppTemplate *hot.Template // These are convenience functions for accessing specific endpoints WWWLogin wwwtemplatebookmark = "login.html" WWWIndex wwwtemplatebookmark = "index.html" WWW404 wwwtemplatebookmark = "404.html" WWWJoin wwwtemplatebookmark = "join.html" AppIndex apptemplatebookmark = "index.html" AppUser apptemplatebookmark = "user.html" AppDevice apptemplatebookmark = "device.html" AppStream apptemplatebookmark = "stream.html" AppError apptemplatebookmark = "error.html" )
var Database *connectordb.Database
Screw it, let's just use a global database
Functions ¶
func Authenticator ¶
func Authenticator(www wwwtemplatebookmark, apifunc webcore.APIHandler, db *connectordb.Database) http.HandlerFunc
Authenticator runs an auth check and either goes to the www template given or to the apifunc handler The only difference here is that the apihandler can return -1 for its log level to instead return the file template (as if no login ever happened)
func Device ¶
func Device(o *authoperator.AuthOperator, writer http.ResponseWriter, request *http.Request, logger *log.Entry) (int, string)
Device reads the given device
func Index ¶
func Index(o *authoperator.AuthOperator, writer http.ResponseWriter, request *http.Request, logger *log.Entry) (int, string)
Index reads the index
func JoinHandleGET ¶
func JoinHandleGET(writer http.ResponseWriter, request *http.Request)
JoinHandleGET handles joining ConnectorDB - the frontend of joining (ie GET)
func JoinHandlePOST ¶
func JoinHandlePOST(writer http.ResponseWriter, request *http.Request)
JoinHandlePOST handles the actual user creation based upon the given structure The only difference here than CRUD CreateUser is that the user creation is done with the admin operator
func Login ¶
func Login(o *authoperator.AuthOperator, writer http.ResponseWriter, request *http.Request, logger *log.Entry) (int, string)
Login handles login to the system without the api call (direct web interface)
func LogoutHandler ¶
func LogoutHandler(writer http.ResponseWriter, request *http.Request)
LogoutHandler handles log out of the system without an api call (direct web interface)
func NotFoundHandler ¶
func NotFoundHandler(writer http.ResponseWriter, request *http.Request)
NotFoundHandler handles all pages that were not found by writing the 404 templates
func Stream ¶
func Stream(o *authoperator.AuthOperator, writer http.ResponseWriter, request *http.Request, logger *log.Entry) (int, string)
Stream reads the given stream
func User ¶
func User(o *authoperator.AuthOperator, writer http.ResponseWriter, request *http.Request, logger *log.Entry) (int, string)
User reads the given user
func VerifyCaptcha ¶
VerifyCaptcha checks if the captcha was solved successfully
func WriteError ¶
func WriteError(logger *log.Entry, writer http.ResponseWriter, status int, err error, iserr bool, tp *TemplateData) (int, string)
WriteError writes the templated error page
Types ¶
type JoinStream ¶
type JoinStream struct { Name string `json:"name"` Nickname string `json:"nickname"` Description string `json:"description"` Icon string `json:"icon"` Schema interface{} `json:"schema"` }
JoinStream is the structure used to encode a stream used for join
type Joiner ¶
Joiner is the struct sent in when POST to join, which creates the desired user structure.
type TemplateData ¶
type TemplateData struct { // Current unix timestamp in seconds since the epoch Timestamp int64 //These are information about the device performing the query ThisUser *users.User ThisDevice *users.Device //This is info about the u/d/s that is being queried User *users.User Device *users.Device Stream *users.Stream //And some extra status info StatusCode int Msg string Ref string //The Database Version Version string // The root URL SiteURL string // contains filtered or unexported fields }
TemplateData is the struct that is passed to the templates
func GetTemplateData ¶
func GetTemplateData(o *authoperator.AuthOperator, request *http.Request) (*TemplateData, error)
GetTemplateData initializes the template
func (*TemplateData) DataURIToAttr ¶
func (td *TemplateData) DataURIToAttr(uri string) template.HTMLAttr
func (*TemplateData) ReadDevices ¶
func (t *TemplateData) ReadDevices() (out []*users.Device, err error)
Reads the devices for the page's user
func (*TemplateData) ReadMyDevices ¶
func (t *TemplateData) ReadMyDevices() (out []*users.Device, err error)
Reads the devices for the user requesting the page
func (*TemplateData) ReadMyStreams ¶
func (t *TemplateData) ReadMyStreams() (out []*users.Stream, err error)
Reads the streams for the user requesting the page
func (*TemplateData) ReadStreams ¶
func (t *TemplateData) ReadStreams() (out []*users.Stream, err error)
Reads the streams for the page's device