controller

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthController

type AuthController struct {
	BaseController
}

func (*AuthController) BasicAuthentication

func (c *AuthController) BasicAuthentication()

Basic authentication method Todo: complete this method to provide basic authentication

func (*AuthController) JWTAuthentication

func (c *AuthController) JWTAuthentication()

User login method. This method will set JWT in HTTP response

type BaseController

type BaseController struct {
	DB       *gorm.DB              // Provide access to MySql instance
	Response http.ResponseWriter   // HTTP response
	Request  *http.Request         // HTTP request
	Config   config.Conf           // Go-Web configuration
	Auth     *service.Auth         // Authentication/Authorization method
	Redis    *redis.Client         // Provide access to Redis instance
	Mongo    *mongo.Database       // Provide access to MongoDB instance
	Elastic  *elasticsearch.Client // Provide access to ElasticSearch instance
	Session  *sessions.CookieStore // Provide access to the CookieStore
}

Main controller structure. This structure determines what you can find in the controllers instance. Adding something else inside this struct will not directly implement the struct. This because is just a part of the controller construction. See the "setBaseController" method inside app/kernel/kernel.go

type Credentials

type Credentials struct {
	Username string `json:"username" valid:"required"`
	Password string `json:"password" valid:"required"`
}

type HomeController

type HomeController struct {
	BaseController
}

func (*HomeController) Main

func (c *HomeController) Main()

Return the Go-Web welcome page. This is just an example of Go-Web controller. With the "c" parameter you've access to the method/properties declared in BaseController (controller.go). Of course you can edit this method with a custom logic.

type UserController

type UserController struct {
	BaseController
}

func (*UserController) Insert

func (c *UserController) Insert()

This method will be used to insert a new user in main DB (SQL)

func (*UserController) Profile

func (c *UserController) Profile()

Used to check authenticated user

Jump to

Keyboard shortcuts

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