evil

package module
v0.0.0-...-7a22eef Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 16 Imported by: 0

README

eviL

eviL View - A Golang server side implementation of Phoenix Live View

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Static embed.FS
View Source
var StaticHandler = http.FileServer(http.FS(Static))

Functions

func ID

func ID() string

func RenderTag

func RenderTag(tag string, attrs map[string]string, content string) (string, error)

Types

type LiveViewChannel

type LiveViewChannel struct {
	Views    map[string]View
	Secret   []byte
	Sessions map[string]*session
	// contains filtered or unexported fields
}

func (*LiveViewChannel) Handle

func (c *LiveViewChannel) Handle(session *melody.Session, m *channel.Message) (interface{}, error)

func (*LiveViewChannel) Join

func (c *LiveViewChannel) Join(session *melody.Session, m *channel.Message) (interface{}, error)

func (*LiveViewChannel) Leave

func (c *LiveViewChannel) Leave(session *melody.Session) error

func (*LiveViewChannel) RegisterView

func (c *LiveViewChannel) RegisterView(view View)

func (*LiveViewChannel) SpawnInstance

func (c *LiveViewChannel) SpawnInstance(id string, view View) (*session, error)

type Server

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

func NewServer

func NewServer(
	secret []byte,
) *Server

func (*Server) Mount

func (s *Server) Mount(path string, view View)

func (*Server) NewToken

func (s *Server) NewToken(id, view string) (string, error)

func (*Server) RenderView

func (s *Server) RenderView(viewName string) (string, error)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Session

type Session interface {
	Done() <-chan struct{}
	Set(key string, value interface{})
}

type SessionClaims

type SessionClaims struct {
	ID   string
	View string
}

func (*SessionClaims) Valid

func (s *SessionClaims) Valid() error

type View

type View interface {
	Template() *template.Template
	OnMount(Session) error
	HandleEvent(Session, *channel.Event) error
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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