Documentation ¶
Index ¶
- func Authentication(s *Server) func(next http.Handler) http.Handler
- func DBInit() (*pgxpool.Pool, error)
- func Error(msg string) error
- func IsAdmin(next http.Handler) http.Handler
- func RespondWithError(w http.ResponseWriter, code int, msg string)
- func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})
- func RespondWithStatusCode(w http.ResponseWriter, code int)
- type Bookmark
- type BookmarkList
- type Bookmarks
- type CreateBookmarkRequest
- type CreateTagRequest
- type CreateUserRequest
- type PaginatedBookmarks
- type Server
- func (s *Server) BookmarkRepositoryCount() (int, error)
- func (s *Server) BookmarkRepositoryDeleteBookmarkByID(bookmarkID string) (int64, error)
- func (s *Server) BookmarkRepositoryGetAllBookmarks(page int, limit int, archived bool, deleted bool, tags []string) ([]*BookmarkList, error)
- func (s *Server) BookmarkRepositoryGetBookmarkByID(bookmarkID string) (Bookmark, error)
- func (s *Server) BookmarkRepositoryInsert(bookmark *CreateBookmarkRequest, userId uint) (int, error)
- func (s *Server) BookmarkRepositoryPatchBookmark(bookmark Bookmark) error
- func (s *Server) BookmarkRepositoryTrashBookmarkByID(bookmarkID string) (int64, error)
- func (s *Server) BookmarkRepositoryUpdateBookmark(bookmark Bookmark) error
- func (s *Server) CorsOptions(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateBookmark(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateTag(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateUser(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteBookmark(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteTag(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteUser(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetBookmark(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListBookmarks(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListTags(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListUsers(w http.ResponseWriter, r *http.Request)
- func (s *Server) MoveBookmarkToTrash(w http.ResponseWriter, r *http.Request)
- func (s *Server) TagsRepositoryCreateTag(bookmarkID int, TagName string) error
- func (s *Server) TagsRepositoryDeleteTagByBookmarkIDAndTagID(bookmarkID int, tagName string) error
- func (s *Server) TagsRepositoryGetTags() (Tags, error)
- func (s *Server) TagsRepositoryGetTagsByBookmarkID(bookmarkID int) (Tags, error)
- func (s *Server) TagsRepositoryUpdateTagByID(tagID int, TagNameUpdate string) error
- func (s *Server) UpdateBookmark(w http.ResponseWriter, r *http.Request)
- func (s *Server) UpdateTag(w http.ResponseWriter, r *http.Request)
- func (s *Server) UpdateUser(w http.ResponseWriter, r *http.Request)
- func (s *Server) UserLogin(w http.ResponseWriter, r *http.Request)
- func (s *Server) UserLogout(w http.ResponseWriter, r *http.Request)
- func (s *Server) UserRepositoryCreate(user *CreateUserRequest) (int, error)
- func (s *Server) UserRepositoryDeleteAccessToken(token string) error
- func (s *Server) UserRepositoryExists(email string, hashed_password string) (int, error)
- func (s *Server) UserRepositoryIsAuthenticated(userId int) (bool, error)
- func (s *Server) UserRepositoryIsAuthenticatedByToken(token string) (User, bool)
- func (s *Server) UserRepositoryList() ([]*User, error)
- func (s *Server) UserRepositoryLogin(userId int) (string, error)
- type Tag
- type Tags
- type UpdateBookmarkRequest
- type UpdateTagRequest
- type User
- type UserLogin
- type Users
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authentication ¶
HTTP middleware setting a value on the request context
func RespondWithError ¶
func RespondWithError(w http.ResponseWriter, code int, msg string)
RespondWithError - Return an error
func RespondWithJSON ¶
func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})
RespondWithJSON - Respond with a json formatted string
func RespondWithStatusCode ¶
func RespondWithStatusCode(w http.ResponseWriter, code int)
RespondWithStatusCode - Respond with a status code without setting a message
Types ¶
type Bookmark ¶
type Bookmark struct { ID uint `json:"id"` Title string `json:"title"` Description string `json:"description"` Body string `json:"body"` Image string `json:"image"` URL string `json:"url"` Archived bool `json:"archived"` Deleted bool `json:"deleted"` Tags string `json:"tags"` CreatedAt time.Time `json:"createdAt"` }
Bookmark Models
type BookmarkList ¶
type BookmarkList struct { ID uint `json:"id"` Title string `json:"title"` Description string `json:"description"` Image string `json:"image"` URL string `json:"url"` Archived bool `json:"archived"` Deleted bool `json:"deleted"` Tags string `json:"tags"` }
Bookmark list model
type Bookmarks ¶
type Bookmarks struct {
Bookmarks []Bookmark
}
Bookmarks - A collection of bookmarks
type CreateBookmarkRequest ¶
type CreateBookmarkRequest struct {
URL string `json:"url"`
}
CreateBookmarkRequest - Used for creating a bookmark
type CreateTagRequest ¶
type CreateUserRequest ¶
type PaginatedBookmarks ¶
type PaginatedBookmarks struct { Page int `json:"page"` TotalPages int `json:"totalPages"` Limit int `json:"limit"` Data []*BookmarkList `json:"data"` }
type Server ¶
Server struct
func (*Server) BookmarkRepositoryCount ¶
BookmarkRepositoryCount Get total amount of bookmarks
func (*Server) BookmarkRepositoryDeleteBookmarkByID ¶
BookmarkRepositoryDeleteBookmarkByID - Delete a specifc bookmark by its database id
func (*Server) BookmarkRepositoryGetAllBookmarks ¶
func (s *Server) BookmarkRepositoryGetAllBookmarks(page int, limit int, archived bool, deleted bool, tags []string) ([]*BookmarkList, error)
BookmarkRepositoryGetAllBookmarks - Get all bookmarks from database
func (*Server) BookmarkRepositoryGetBookmarkByID ¶
BookmarkRepositoryGetBook.markByID - Get a specifc bookmark by its database id
func (*Server) BookmarkRepositoryInsert ¶
func (s *Server) BookmarkRepositoryInsert(bookmark *CreateBookmarkRequest, userId uint) (int, error)
BookmarkRepositoryInsert - Insert bookmark into database
func (*Server) BookmarkRepositoryPatchBookmark ¶
BookmarkRepositoryPatchBookmark - Patch a specifc bookmark by its database id
func (*Server) BookmarkRepositoryTrashBookmarkByID ¶
BookmarkRepositoryTrashBookmarkByID - Mark bookmark as deleted
func (*Server) BookmarkRepositoryUpdateBookmark ¶
BookmarkRepositoryUpdateBookmark - Update a specifc bookmark by its database id
func (*Server) CorsOptions ¶
func (s *Server) CorsOptions(w http.ResponseWriter, r *http.Request)
DeleteBookmark Delete a specific bookmark by its ID
func (*Server) CreateBookmark ¶
func (s *Server) CreateBookmark(w http.ResponseWriter, r *http.Request)
CreateBookmark Create bookmark
func (*Server) CreateUser ¶
func (s *Server) CreateUser(w http.ResponseWriter, r *http.Request)
Only admin can run user APIs
func (*Server) DeleteBookmark ¶
func (s *Server) DeleteBookmark(w http.ResponseWriter, r *http.Request)
DeleteBookmark Delete a specific bookmark by its ID
func (*Server) DeleteUser ¶
func (s *Server) DeleteUser(w http.ResponseWriter, r *http.Request)
func (*Server) GetBookmark ¶
func (s *Server) GetBookmark(w http.ResponseWriter, r *http.Request)
GetBookmark Get a specific bookmark by its ID
func (*Server) ListBookmarks ¶
func (s *Server) ListBookmarks(w http.ResponseWriter, r *http.Request)
ListBookmarks Return all bookmarks
func (*Server) MoveBookmarkToTrash ¶
func (s *Server) MoveBookmarkToTrash(w http.ResponseWriter, r *http.Request)
DeleteBookmark Delete a specific bookmark by its ID
func (*Server) TagsRepositoryCreateTag ¶
func (*Server) TagsRepositoryDeleteTagByBookmarkIDAndTagID ¶
func (*Server) TagsRepositoryGetTags ¶
func (*Server) TagsRepositoryGetTagsByBookmarkID ¶
func (*Server) TagsRepositoryUpdateTagByID ¶
func (*Server) UpdateBookmark ¶
func (s *Server) UpdateBookmark(w http.ResponseWriter, r *http.Request)
UpdateBookmark Update a bookmark by its ID
func (*Server) UpdateUser ¶
func (s *Server) UpdateUser(w http.ResponseWriter, r *http.Request)
func (*Server) UserLogout ¶
func (s *Server) UserLogout(w http.ResponseWriter, r *http.Request)
func (*Server) UserRepositoryCreate ¶
func (s *Server) UserRepositoryCreate(user *CreateUserRequest) (int, error)
UserRepositoryCreate - Creates a new user in DB
func (*Server) UserRepositoryDeleteAccessToken ¶
func (*Server) UserRepositoryExists ¶
func (*Server) UserRepositoryIsAuthenticated ¶
func (*Server) UserRepositoryIsAuthenticatedByToken ¶
func (*Server) UserRepositoryList ¶
UserRepositoryList - List all users
type UpdateBookmarkRequest ¶
type UpdateBookmarkRequest struct { Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Body string `json:"body,omitempty"` Image string `json:"image,omitempty"` URL string `json:"url,omitempty"` Archived *bool `json:"archived,omitempty"` Deleted *bool `json:"deleted,omitempty"` }
UpdateBookmarkRequest - PUT/PATCH object
type UpdateTagRequest ¶
type UpdateTagRequest struct {
TagName string `json:"tagName"`
}