Documentation ¶
Index ¶
- type AddPostRequest
- type AssetCache
- type ConstantFileOptions
- type ImageData
- type LoginUser
- type PostDB
- type PostListBody
- type PublicUser
- type RouteTemplate
- type SentUser
- type Server
- func (srv *Server) APIAddPost(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIAddUser(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIAuthToID(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIDownloadImage(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIGetCommentsFromPost(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIGetPostFromID(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIGetPostsFromUser(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIGetUserPostHistory(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APILoginUser(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIPostFeed(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIPostFeedList(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APISearchForUsers(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APISearchPost(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIUploadImage(w http.ResponseWriter, r *http.Request)
- func (srv *Server) APIUserFromID(w http.ResponseWriter, r *http.Request)
- func (srv *Server) AssetFiles(w http.ResponseWriter, r *http.Request)
- func (srv *Server) AuthToID(auth string) (int, error)
- func (srv *Server) ConstantFile(Options ConstantFileOptions) http.HandlerFunc
- func (srv *Server) IDToUser(ID int) (*User, error)
- func (srv *Server) InitTable()
- func (srv *Server) LoadAssets()
- func (srv *Server) Routes()
- func (srv *Server) Run()
- func (srv *Server) SendAssetsFile(w http.ResponseWriter, r *http.Request, Data AssetCache)
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddPostRequest ¶
type AddPostRequest struct { PostedBy int `json:"postedBy" db:"PostedBy"` Content string `json:"content" db:"content"` ParentID int `json:"parentID" db:"ParentId"` Images string `json:"images" db:"images"` }
AddPostRequest struct should be used for request for adding a new Post in the database
type AssetCache ¶
type AssetCache struct { File *utility.FileMime // The filedata FileInfo fs.FileInfo // The file metadata Err error // The Error being return (optional) Code int // The code being returned ETag string // The file's ETag }
AssetCache is represents the Asset stored in the Cache
type ConstantFileOptions ¶
ConstantFileOptions is for the method github.com/Blockitifluy/CoffeeCo/api.ConstantFile
type ImageData ¶
type ImageData struct { URL string `db:"URL"` Content []byte `db:"content"` ContentType string `db:"mimetype"` }
ImageData contains the URL, content, content-type of an image
type LoginUser ¶
type LoginUser struct { Handle string `json:"handle" db:"handle"` // A unique name of the User Password string `json:"password"` // Unhashed password }
LoginUser is used for login users and contains:
- Handle
- Password (hasn't been hashed yet)
type PostDB ¶
type PostDB struct { ID int `json:"ID" db:"ID"` PostedBy int `json:"postedBy" db:"postedBy"` Content string `json:"content" db:"content"` TimeCreated time.Time `json:"timeCreated" db:"timeCreated"` ParentID int `json:"parentID" db:"parentID"` WhoLiked string `json:"whoLiked" db:"whoLiked"` WhoDisliked string `json:"whoDisliked" db:"whoDisliked"` Likes int `json:"likes" db:"likes"` Dislikes int `json:"dislikes" db:"dislikes"` Images string `json:"images" db:"images"` }
PostDB is a struct replicata of the `Posts` table
type PostListBody ¶
type PostListBody struct {
Amount int `json:"amount"`
}
PostListBody is used by coffeecoserver/api.server.PostFeedList and only contains Amount int value.
type PublicUser ¶
type PublicUser struct { ID int `json:"ID" db:"ID"` Username string `json:"username" db:"username"` // A non-unique name Handle string `json:"handle" db:"handle"` // An unique handle Bio string `json:"bio" db:"bio"` // The description (biography) Followers int `json:"followers" db:"followers"` WhoFollowed string `json:"whoFollowed" db:"whoFollowed"` // How many users following Banner string `json:"Banner" db:"banner"` // Url to the Banner Profile string `json:"Profile" db:"profile"` // Url to the Profile }
PublicUser is the root of most User structs contains non-personal information about the user
type RouteTemplate ¶
type RouteTemplate struct { Methods []string Funct http.HandlerFunc // contains filtered or unexported fields }
RouteTemplate is a server route, not yet loaded by the server
type SentUser ¶
type SentUser struct { *PublicUser Password string `json:"password"` // unhashed password Email string `json:"email" db:"email"` }
SentUser contains all the regular information from coffeecoserver/api.PublicUser as well as:
- Password
type Server ¶
Server contains:
- Server (Gorilla Mux),
- Database (Sqlite)
func (*Server) APIAddPost ¶
func (srv *Server) APIAddPost(w http.ResponseWriter, r *http.Request)
APIAddPost is an API call do not use outside of http requests
Adds a post to database. See more at coffeecoserver/api.AddPostRequest.
func (*Server) APIAddUser ¶
func (srv *Server) APIAddUser(w http.ResponseWriter, r *http.Request)
APIAddUser is an api call. Doesn't work as expected when called outside an API context
Add user using the SentUser struct
func (*Server) APIAuthToID ¶
func (srv *Server) APIAuthToID(w http.ResponseWriter, r *http.Request)
APIAuthToID is an api call. Doesn't work as expected when called outside an API context
Get a user's id using authorisation token via url
func (*Server) APIDownloadImage ¶
func (srv *Server) APIDownloadImage(w http.ResponseWriter, r *http.Request)
APIDownloadImage is an api call. Doesn't work as expected when called outside an API context
Retrieves an image from the batabase, compress for network
func (*Server) APIGetCommentsFromPost ¶
func (srv *Server) APIGetCommentsFromPost(w http.ResponseWriter, r *http.Request)
APIGetCommentsFromPost is an API call, only use in HTTP contexts
Get a the comment from a Post
func (*Server) APIGetPostFromID ¶
func (srv *Server) APIGetPostFromID(w http.ResponseWriter, r *http.Request)
APIGetPostFromID is an API call, only use in HTTP contexts
Get a post based on the ID given
func (*Server) APIGetPostsFromUser ¶
func (srv *Server) APIGetPostsFromUser(w http.ResponseWriter, r *http.Request)
APIGetPostsFromUser is an API call do not use outside of http requests
Gets a x amount of Posts from a User (Provided by ID)
func (*Server) APIGetUserPostHistory ¶
func (srv *Server) APIGetUserPostHistory(w http.ResponseWriter, r *http.Request)
APIGetUserPostHistory is an API call do not use outside of http requests
Gets posts from a range by an user
func (*Server) APILoginUser ¶
func (srv *Server) APILoginUser(w http.ResponseWriter, r *http.Request)
APILoginUser is an api call. Doesn't work as expected when called outside an API context
Logs in user via password and username
func (*Server) APIPostFeed ¶
func (srv *Server) APIPostFeed(w http.ResponseWriter, r *http.Request)
APIPostFeed is an API call do not use outside of http requests
This is a work in progress will change in the future
func (*Server) APIPostFeedList ¶
func (srv *Server) APIPostFeedList(w http.ResponseWriter, r *http.Request)
APIPostFeedList is an API call do not use outside of http requests
This returns a list version of coffeecoserver/api.Server.PostFeed
func (*Server) APISearchForUsers ¶
func (srv *Server) APISearchForUsers(w http.ResponseWriter, r *http.Request)
APISearchForUsers is an api call. Doesn't work as expected when called outside an API context
Searches user by username and handle (Feed Type)
func (*Server) APISearchPost ¶
func (srv *Server) APISearchPost(w http.ResponseWriter, r *http.Request)
APISearchPost is an API call do not use outside of http requests
Searches posts by content (Feed Type)
func (*Server) APIUploadImage ¶
func (srv *Server) APIUploadImage(w http.ResponseWriter, r *http.Request)
APIUploadImage is an api call. Doesn't work as expected when called outside an API context
Uploads an image (png, jpeg and gif) with a limited size, compresses it and add to database
func (*Server) APIUserFromID ¶
func (srv *Server) APIUserFromID(w http.ResponseWriter, r *http.Request)
APIUserFromID is an api call. Doesn't work as expected when called outside an API context
Get a user based on the id given via url.
func (*Server) AssetFiles ¶
func (srv *Server) AssetFiles(w http.ResponseWriter, r *http.Request)
AssetFiles is an api call. Doesn't work as expected when called outside an API context
Sends files from `dist/assets` and caches it
func (*Server) ConstantFile ¶
func (srv *Server) ConstantFile(Options ConstantFileOptions) http.HandlerFunc
ConstantFile is an api call. Doesn't work as expected when called outside an API context
First, reads and caches file then sends to client
func (*Server) InitTable ¶
func (srv *Server) InitTable()
InitTable adds tables to the database if the database already has been initated
func (*Server) Routes ¶
func (srv *Server) Routes()
Routes method adds routes to the server (Self explainitary)
func (*Server) SendAssetsFile ¶
func (srv *Server) SendAssetsFile(w http.ResponseWriter, r *http.Request, Data AssetCache)
SendAssetsFile sends the AssetCache to the client
type User ¶
type User struct { *PublicUser Email string `json:"email" db:"email"` Auth string `json:"auth" db:"auth"` // Authorisation Token // contains filtered or unexported fields }
User contains all the user information provided from the database
func (*User) GenerateAuth ¶
GenerateAuth generates an auth token from the user