view

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map map[string]interface{}

Map is a convenience function for the common case of passing a map of props into a view

type Renderer

type Renderer interface {
	Render(path string, props interface{}) (*Response, error)
}

Renderer interface

type Response

type Response struct {
	Status  int               `json:"status,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Body    string            `json:"body,omitempty"`
}

func (*Response) Write

func (res *Response) Write(w http.ResponseWriter)

type Server

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

func Live

func Live(module *gomod.Module, overlay *overlay.FileSystem, vm js.VM, transformer *transform.Map, wrapProps func(path string, props interface{}) interface{}) *Server

Live server serves view files on the fly. Used during development.

func Static

func Static(fsys fs.FS, vm js.VM, wrapProps func(path string, props interface{}) interface{}) *Server

Static server serves the same files every time. Used during production.

func (*Server) Handler

func (s *Server) Handler(route string, props interface{}) http.Handler

Handler returns a handler for a specific server-side route

func (*Server) Middleware

func (s *Server) Middleware(next http.Handler) http.Handler

func (*Server) Render

func (s *Server) Render(path string, props interface{}) (*Response, error)

func (*Server) Respond

func (s *Server) Respond(w http.ResponseWriter, path string, props interface{})

Respond is a convenience function for render

func (*Server) ServeHTTP

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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