controllers

package
v0.0.0-...-5b087d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

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 APIError

type APIError struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Status  int    `json:"status"`
}

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

func GetJSON(reader io.Reader) (*JsonData, error)

Inspiration taken from https://github.com/antonholmquist/jason/ TODO: Move into a util package maybe? or again into some interface the basecontroller is using

func (*JsonData) GetInt

func (d *JsonData) GetInt(key string) (int, error)

func (*JsonData) GetString

func (d *JsonData) GetString(key string) (string, error)

type PostController

type PostController struct {
	*app.App
	repositories.PostRepository
	repositories.UserRepository
}

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 (*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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL