web_utils

package
v0.0.0-...-0eac02a Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const CookieAccessToken = "JWT_ACCESS"
View Source
const CookieRefreshToken = "JWT_REFRESH"
View Source
const CookieSessionToken = "JWT_SESSION"

Variables

This section is empty.

Functions

func DecodeRedirectState

func DecodeRedirectState(state string) (string, error)

func EncodeRedirectState

func EncodeRedirectState(state []byte) string

func EncodeUrlAndQuery

func EncodeUrlAndQuery(url *url.URL) string

func JsonDecode

func JsonDecode(data string, result interface{}) error

func JsonEncode

func JsonEncode(data interface{}) (string, error)

func OAuth2ParseAuthorizationRequest

func OAuth2ParseAuthorizationRequest(request *gin.Context) auth.OAuth2AuthRequest

func ToBase64Url

func ToBase64Url(bytes []byte) string

Types

type Controller

type Controller interface {
	RegisterRoutes(router *gin.RouterGroup)
}

type ControllerContext

type ControllerContext struct {
	context.Context
	Gin *gin.Context
}

type ErrorPageParams

type ErrorPageParams struct {
	Message string
	Error   string
	Title   string
}

type Tools

type Tools struct {
	App *core.GouthyApp
}

func NewHTTPTools

func NewHTTPTools(app *core.GouthyApp) *Tools

func (*Tools) EncodeCurrentUrl

func (tool *Tools) EncodeCurrentUrl(ctx context.Context) string

func (*Tools) ErrorPage

func (tool *Tools) ErrorPage(ctx context.Context, params ErrorPageParams)

func (*Tools) ExtractJwt

func (tool *Tools) ExtractJwt(ctx context.Context) (jwtlib.Jwt, error)

func (*Tools) Fail

func (tool *Tools) Fail(ctx context.Context, err api_errors.ApiError)

func (*Tools) GetCurrentApp

func (tool *Tools) GetCurrentApp(ctx context.Context) (*apps.Application, error)

func (*Tools) GetCurrentUserAndApp

func (tool *Tools) GetCurrentUserAndApp(ctx context.Context) (dto *users.UserDTO, appDTO *apps.AppDTO, err error)

func (*Tools) GetIdentity

func (tool *Tools) GetIdentity(ctx context.Context) *auth.LoginIdentity

func (*Tools) GetLoggedInUser

func (tool *Tools) GetLoggedInUser(ctx context.Context) *users.UserDTO

func (*Tools) GetRedirectState

func (tool *Tools) GetRedirectState(ctx context.Context) string

func (*Tools) Gin

func (tool *Tools) Gin(ctx context.Context) *gin.Context

func (*Tools) HTML

func (tool *Tools) HTML(ctx context.Context, code int, template string, params gin.H)

func (*Tools) JSON

func (tool *Tools) JSON(ctx context.Context, code int, obj interface{})

func (*Tools) NewControllerContext

func (tool *Tools) NewControllerContext(gin *gin.Context) context.Context

func (*Tools) Param

func (tool *Tools) Param(ctx context.Context, key string) string

func (*Tools) Redirect

func (tool *Tools) Redirect(ctx context.Context, url string)

func (*Tools) RedirectToLogin

func (tool *Tools) RedirectToLogin(ctx context.Context)

func (*Tools) RedirectWithRedirectState

func (tool *Tools) RedirectWithRedirectState(ctx context.Context, defaultRedirect string) error

func (*Tools) WriteErr

func (tool *Tools) WriteErr(ctx context.Context, err error)

Jump to

Keyboard shortcuts

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