controller

package
v0.0.0-...-785145d Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OAuthProviderGoogle is the google auth provider.
	OAuthProviderGoogle = "google"
	// OAuthProviderFacebook is the facebook auth provider.
	OAuthProviderFacebook = "facebook"
	// OAuthProviderSlack is the google auth provider.
	OAuthProviderSlack = "slack"
)
View Source
const (
	// SessionStateUserKey is the key we store the user in the session state.
	SessionStateUserKey = "User"
)

Variables

This section is empty.

Functions

func APIProviderAsDefault

func APIProviderAsDefault(action web.Action) web.Action

APIProviderAsDefault sets the context.CurrrentProvider() equal to context.API().

func CreateImageFromFile

func CreateImageFromFile(ctx context.Context, mgr *model.Manager, userID int64, shouldValidate bool, fileContents []byte, fileName string, fm *filemanager.FileManager) (*model.Image, error)

CreateImageFromFile creates and uploads a new image.

func GetUser

func GetUser(session *web.Session) *model.User

GetUser returns the user state from a session.

func SetUser

func SetUser(session *web.Session, user *model.User)

SetUser stores a user on a session.

Types

type APIResponse

type APIResponse struct {
	Meta     *APIResponseMeta
	Response interface{}
}

APIResponse is the standard API response format.

type APIResponseMeta

type APIResponseMeta struct {
	StatusCode int
	Message    string        `json:",omitempty"`
	Exception  *exception.Ex `json:",omitempty"`
}

APIResponseMeta is the meta component of a service response.

type APIResultProvider

type APIResultProvider struct {
	// contains filtered or unexported fields
}

APIResultProvider are context results for api methods.

func API

func API(ctx *web.Ctx) *APIResultProvider

API returns the api result provider.

func NewAPIResultProvider

func NewAPIResultProvider(r *web.Ctx) *APIResultProvider

NewAPIResultProvider Creates a new JSONResults object.

func (*APIResultProvider) BadRequest

func (ar *APIResultProvider) BadRequest(err error) web.Result

BadRequest returns a service response.

func (*APIResultProvider) InternalError

func (ar *APIResultProvider) InternalError(err error) web.Result

InternalError returns a service response.

func (*APIResultProvider) NotAuthorized

func (ar *APIResultProvider) NotAuthorized() web.Result

NotAuthorized returns a service response.

func (*APIResultProvider) NotFound

func (ar *APIResultProvider) NotFound() web.Result

NotFound returns a service response.

func (*APIResultProvider) OK

func (ar *APIResultProvider) OK() web.Result

OK returns a service response.

func (*APIResultProvider) Result

func (ar *APIResultProvider) Result(response interface{}) web.Result

Result returns a service response.

func (*APIResultProvider) Status

func (ar *APIResultProvider) Status(statusCode int, data interface{}) web.Result

Status returns a service response.

type APIs

type APIs struct {
	Log    logger.Log
	Config *config.Giffy
	Model  *model.Manager
	OAuth  *oauth.Manager
	Files  *filemanager.FileManager
}

APIs is the controller for api endpoints.

func (APIs) Register

func (api APIs) Register(app *web.App)

Register adds the routes to the app.

type Auth

type Auth struct {
	Log    logger.Log
	OAuth  *oauth.Manager
	Config *config.Giffy
	Model  *model.Manager
}

Auth is the main controller for the app.

func (Auth) Register

func (ac Auth) Register(app *web.App)

Register registers the controllers routes.

type Chart

type Chart struct {
	Log    logger.Log
	Config *config.Giffy
	Model  *model.Manager
}

Chart is a controller for common chart endpoints.

func (Chart) Register

func (c Chart) Register(app *web.App)

Register registers the controller.

type Index

type Index struct {
	Log    logger.Log
	Config *config.Giffy
	Model  *model.Manager
}

Index is the root controller.

func (Index) Register

func (i Index) Register(app *web.App)

Register registers the controller

type Integrations

type Integrations struct {
	Log    logger.Log
	Config *config.Giffy
	Model  *model.Manager
}

Integrations controller is responsible for integration responses.

func (Integrations) Register

func (i Integrations) Register(app *web.App)

Register registers the controller's actions with the app.

type UploadImage

type UploadImage struct {
	Log    logger.Log
	Config *config.Giffy
	Model  *model.Manager
	Files  *filemanager.FileManager
}

UploadImage is the controller responsible for image actions.

func (UploadImage) FetchImageFromURL

func (ic UploadImage) FetchImageFromURL(imageURL string) (fileName string, fileContents []byte, err error)

func (UploadImage) Register

func (ic UploadImage) Register(app *web.App)

Register registers the controllers routes.

Jump to

Keyboard shortcuts

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