Documentation
¶
Index ¶
- Constants
- func NewAPIError(e *APIError, w http.ResponseWriter)
- func NewAPIResponse(res *APIResponse, w http.ResponseWriter, code int)
- type APIError
- type APIPagination
- type APIResponse
- type AuthController
- func (ac *AuthController) Authenticate(w http.ResponseWriter, r *http.Request)
- func (ac *AuthController) Logout(w http.ResponseWriter, r *http.Request)
- func (ac *AuthController) LogoutAll(w http.ResponseWriter, r *http.Request)
- func (ac *AuthController) RefreshTokens(w http.ResponseWriter, r *http.Request)
- type JsonData
- type PostController
- func (pc *PostController) Create(w http.ResponseWriter, r *http.Request)
- func (pc *PostController) GetAll(w http.ResponseWriter, r *http.Request)
- func (pc *PostController) GetById(w http.ResponseWriter, r *http.Request)
- func (pc *PostController) GetBySlug(w http.ResponseWriter, r *http.Request)
- func (pc *PostController) Update(w http.ResponseWriter, r *http.Request)
- type PostPaginator
- type UploadController
- type UploadImageResponse
- type UserController
- func (uc *UserController) Create(w http.ResponseWriter, r *http.Request)
- func (uc *UserController) FindPostsByUser(w http.ResponseWriter, r *http.Request)
- func (uc *UserController) GetAll(w http.ResponseWriter, r *http.Request)
- func (uc *UserController) GetById(w http.ResponseWriter, r *http.Request)
- func (uc *UserController) HelloWorld(w http.ResponseWriter, r *http.Request)
- func (uc *UserController) Profile(w http.ResponseWriter, r *http.Request)
- func (uc *UserController) Update(w http.ResponseWriter, r *http.Request)
Constants ¶
View Source
const (
MB = 1 << 20
)
Variables ¶
This section is empty.
Functions ¶
func NewAPIError ¶
func NewAPIError(e *APIError, w http.ResponseWriter)
func NewAPIResponse ¶
func NewAPIResponse(res *APIResponse, w http.ResponseWriter, code int)
TODO: Use this for both the APIResponse and APIError type
Types ¶
type APIPagination ¶
type APIPagination struct {
Total int `json:"total"`
PerPage int `json:"perPage"`
CurrentPage int `json:"currentPage"`
LastPage int `json:"lastPage"`
From int `json:"from"`
To int `json:"to"`
FirstPageURL string `json:"firstPageUrl"`
LastPageURL string `json:"lastPageUrl"`
NextPageURL string `json:"nextPageUrl"`
PrevPageURL string `json:"prevPageUrl"`
}
func (*APIPagination) MarshalJSON ¶
func (p *APIPagination) MarshalJSON() ([]byte, error)
type APIResponse ¶
type APIResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Data interface{} `json:"data,omitempty"`
Pagination *APIPagination `json:"pagination,omitempty"`
}
type AuthController ¶
type AuthController struct {
App *app.App
repositories.UserRepository
// contains filtered or unexported fields
}
func NewAuthController ¶
func NewAuthController(a *app.App, us repositories.UserRepository, jwtService services.JWTAuthService) *AuthController
func (*AuthController) Authenticate ¶
func (ac *AuthController) Authenticate(w http.ResponseWriter, r *http.Request)
func (*AuthController) Logout ¶
func (ac *AuthController) Logout(w http.ResponseWriter, r *http.Request)
func (*AuthController) LogoutAll ¶
func (ac *AuthController) LogoutAll(w http.ResponseWriter, r *http.Request)
func (*AuthController) RefreshTokens ¶
func (ac *AuthController) RefreshTokens(w http.ResponseWriter, r *http.Request)
type JsonData ¶
type JsonData struct {
// contains filtered or unexported fields
}
func GetJSON ¶
Inspiration taken from https://github.com/antonholmquist/jason/ TODO: Move into a util package maybe? or again into some interface the basecontroller is using
type PostController ¶
type PostController struct {
*app.App
repositories.PostRepository
repositories.UserRepository
}
func NewPostController ¶
func NewPostController(a *app.App, pr repositories.PostRepository, ur repositories.UserRepository) *PostController
func (*PostController) Create ¶
func (pc *PostController) Create(w http.ResponseWriter, r *http.Request)
func (*PostController) GetAll ¶
func (pc *PostController) GetAll(w http.ResponseWriter, r *http.Request)
func (*PostController) GetById ¶
func (pc *PostController) GetById(w http.ResponseWriter, r *http.Request)
func (*PostController) GetBySlug ¶
func (pc *PostController) GetBySlug(w http.ResponseWriter, r *http.Request)
func (*PostController) Update ¶
func (pc *PostController) Update(w http.ResponseWriter, r *http.Request)
type PostPaginator ¶
type PostPaginator struct {
Total int `json:"total"`
PerPage int `json:"perPage"`
CurrentPage int `json:"currentPage"`
LastPage int `json:"lastPage"`
From int `json:"from"`
To int `json:"to"`
FirstPageUrl string `json:"firstPageUrl"`
LastPageUrl string `json:"lastPageUrl"`
NextPageUrl *string `json:"nextPageUrl"`
PrevPageUrl *string `json:"prevPageUrl"`
}
type UploadController ¶
type UploadController struct{}
func NewUploadController ¶
func NewUploadController() *UploadController
func (*UploadController) UploadImage ¶
func (uc *UploadController) UploadImage(w http.ResponseWriter, r *http.Request)
type UploadImageResponse ¶
type UploadImageResponse struct {
ImageURL string `json:"imageUrl"`
}
type UserController ¶
type UserController struct {
*app.App
repositories.UserRepository
repositories.PostRepository
}
Embed a UserDAO/Repository thingy
func NewUserController ¶
func NewUserController(a *app.App, ur repositories.UserRepository, pr repositories.PostRepository) *UserController
func (*UserController) Create ¶
func (uc *UserController) Create(w http.ResponseWriter, r *http.Request)
func (*UserController) FindPostsByUser ¶
func (uc *UserController) FindPostsByUser(w http.ResponseWriter, r *http.Request)
func (*UserController) GetAll ¶
func (uc *UserController) GetAll(w http.ResponseWriter, r *http.Request)
func (*UserController) GetById ¶
func (uc *UserController) GetById(w http.ResponseWriter, r *http.Request)
func (*UserController) HelloWorld ¶
func (uc *UserController) HelloWorld(w http.ResponseWriter, r *http.Request)
func (*UserController) Profile ¶
func (uc *UserController) Profile(w http.ResponseWriter, r *http.Request)
func (*UserController) Update ¶
func (uc *UserController) Update(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.