framework

package
v0.0.0-...-747cc42 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CookieExpireDelete = time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)

CookieExpireDelete may be set on Cookie.Expire for expiring the given cookie.

Functions

This section is empty.

Types

type App

type App interface {
	Start() error
	Use(m Middleware)
	UseFunc(f MiddlewareFunc)
}

App represents the AskMe application server

func NewApp

func NewApp(
	config *Config,
	ctrl Router,
	fileProvider FileProvider,
	sessionStore SessionManager) App

NewApp Creates a new app server

type Config

type Config struct {
	Debug              bool
	Port               int
	PublicFolder       string
	SessionMaxLifeTime time.Duration
	SessionCookie      string
	PostgresUser       string
	PostgresPassword   string
	PostgresDB         string
	PostgresHost       string
	OktaClient         string
	OktaSecret         string
	OktaIssuer         string
	OktaSocialIdps     []OktaSocialIdp
}

Config configuration

type Connection

type Connection interface {
	Connect() (*gorm.DB, error)
}

Connection interface

func NewConnection

func NewConnection(config *Config) Connection

NewConnection creates a new connection

type Context

type Context interface {
	Session() *Session
	Request() *http.Request
	ResponseWriter() http.ResponseWriter
	Params() httprouter.Params
	User() *User
	Redirect(path string, code int)
	SetUser(*User)
}

Context type

type FileProvider

type FileProvider interface {
	List() []string
	String(name string) string
	Open(name string) (http.File, error)
}

FileProvider fetches files by name

type Map

type Map map[string]interface{}

Map string to objects

type Middleware

type Middleware interface {
	Run(context Context) bool
}

Middleware interface

type MiddlewareFunc

type MiddlewareFunc func(context Context) bool

MiddlewareFunc adapter for funcs to middleware

func (MiddlewareFunc) Run

func (f MiddlewareFunc) Run(context Context) bool

Run middleware func

type OktaSocialIdp

type OktaSocialIdp struct {
	ID   string
	Name string
}

OktaSocialIdp configuration

type Renderer

type Renderer interface {
	Render(w http.ResponseWriter, p ViewModel)
}

Renderer type

func NewRenderer

func NewRenderer(fp FileProvider, config *Config) Renderer

NewRenderer creates a new rendere

type Route

type Route struct {
	Method  string
	Path    string
	Options *RouteOptions
	Func    RouteHandler
}

Route captures the http actions of the controller

func (*Route) Authenticated

func (rt *Route) Authenticated() *Route

Authenticated Adds authentication options

type RouteAdapter

type RouteAdapter func(f RouteHandler) RouteHandler

type RouteHandler

type RouteHandler func(context Context)

RouteHandler defines handler

func AdaptRoute

func AdaptRoute(h RouteHandler, adapters ...RouteAdapter) RouteHandler

type RouteOptions

type RouteOptions struct {
	AuthRequired bool
}

RouteOptions settings

type Router

type Router interface {
	Routes() []*Route
	Get(string, RouteHandler) *Route
	Post(string, RouteHandler) *Route
	Delete(string, RouteHandler) *Route
	Put(string, RouteHandler) *Route
}

Router interface

func NewRouter

func NewRouter() Router

NewRouter initializes the controller

type Session

type Session struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Session represents web session

func (*Session) Get

func (s *Session) Get(key string) interface{}

Get the value for the specified key

func (*Session) ID

func (s *Session) ID() SessionID

ID returns the SessionID

func (*Session) Set

func (s *Session) Set(key string, val interface{})

Set the key value pair specified to the session

type SessionID

type SessionID string

SessionID unique session identifier

type SessionManager

type SessionManager interface {
	FetchOrCreate(Context) *Session
	Abandon(Context)
}

SessionManager stores session info

func NewInMemorySessionStore

func NewInMemorySessionStore(config *Config) SessionManager

NewInMemorySessionStore creates a new InMemory SessionStore

type User

type User struct {
	ID   string
	Name string
}

User struct

type ViewModel

type ViewModel struct {
	BodyTmpl string
	HeadTmpl string
	Title    string
	Bag      Map
}

ViewModel defines the page ViewModel

Jump to

Keyboard shortcuts

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