api_callback

package
Version: v0.0.0-...-62fa0c4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathPing        = "/ping"
	PathConnect     = "/connect/auth"
	PathSuccess     = "/success"
	PathFailure     = "/failure"
	PathHello       = "/hello"
	DataUriImagePng = "data:image/png;base64,"
)

Variables

View Source
var (
	ErrorAnotherServerOnline = errors.New("another server is online")
	MCallback                = app_msg.Apply(&MsgCallback{}).(*MsgCallback)
)

Functions

This section is empty.

Types

type Callback

type Callback interface {
	// Auth redirect url
	Url() string

	// Execute OAuth2 flow. This is blocking operation.
	Flow() error

	// Startup the server, this is blocking operation.
	Start() error

	// Shutdown the server
	Shutdown()

	// Wait for the server readiness
	WaitServerReady() bool

	// Handler for web server status check
	Ping(g *gin.Context)

	// Handler for callback
	Connect(g *gin.Context)

	// Handler for Authentication success
	Success(g *gin.Context)

	// Handler for Authentication failure
	Failure(g *gin.Context)
}

func New

func New(ctl app_control.Control, s Service, port int) Callback

func NewWithOpener

func NewWithOpener(ctl app_control.Control, s Service, port int, opener es_open.Open) Callback

type MsgCallback

type MsgCallback struct {
	MsgOpenUrlOnYourBrowser      app_msg.Message
	MsgErrorOpenUrlOnYourBrowser app_msg.Message
	MsgHitEnterToProceed         app_msg.Message
	MsgResultSuccessHeader       app_msg.Message
	MsgResultSuccessBody         app_msg.Message
	MsgResultFailureHeader       app_msg.Message
	MsgResultFailureBody         app_msg.Message
	MsgHelloHeader               app_msg.Message
	MsgHelloBody                 app_msg.Message
}

type ServerStatus

type ServerStatus struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Token   string `json:"token"`
}

type Service

type Service interface {
	// Compose redirect url that must contain csrf token param `state`.
	Url(redirectUrl string) string

	// Verify with csrf token `state`, and `code` to proceed acquire token.
	Verify(state, code string) bool
}

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to