fastboot

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler is a http.Handler that will pre-render the given ember app.

func Handle

func Handle(options Options) (*Handler, error)

Handle will create a new handler.

func (*Handler) Close

func (h *Handler) Close()

Close will close the handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

type Instance

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

Instance represents a running Fastboot instance.

func Boot

func Boot(app *ember.App, origin string, headed bool) (*Instance, error)

Boot will boot the provided Fastboot-capable app in a headless browser and return a running instance.

func (*Instance) Close

func (i *Instance) Close()

Close will close the instance and release all resources.

func (*Instance) Visit

func (i *Instance) Visit(url string, r Request, timeout time.Duration) (Result, error)

Visit will visit the provided URL and return the result.

type Options

type Options struct {
	App       *ember.App
	Origin    string
	Timeout   time.Duration // 5s
	Cache     time.Duration
	Isolated  bool
	Headed    bool
	OnRequest func(*Request)
	OnResult  func(*Result)
	OnError   func(error)
}

Options are used to configure the handler.

type Request

type Request struct {
	Method      string              `json:"method"`
	Protocol    string              `json:"protocol"`
	Path        string              `json:"path"`
	Headers     map[string][]string `json:"headers"`
	Cookies     map[string]string   `json:"cookies"`
	QueryParams map[string]string   `json:"queryParams"`
	Body        string              `json:"body"`
}

Request represents a request to be made.

type Result

type Result struct {
	HeadContent    string            `json:"headContent"`
	BodyContent    string            `json:"bodyContent"`
	HTMLAttributes map[string]string `json:"htmlAttributes"`
	HeadAttributes map[string]string `json:"headAttributes"`
	BodyAttributes map[string]string `json:"bodyAttributes"`
}

Result represents the result of an instance visit.

func Render

func Render(app *ember.App, location string, r Request, timeout time.Duration) (Result, error)

Render will run the provided app in a headless browser and return the HTML output for the specified URL.

func (*Result) BodyAttributesString

func (r *Result) BodyAttributesString() string

BodyAttributesString will return the body attributes as a string.

func (*Result) HTML

func (r *Result) HTML() string

HTML will build and return the full document.

func (*Result) HTMLAttributesString

func (r *Result) HTMLAttributesString() string

HTMLAttributesString will return the HTML attributes as a string.

func (*Result) HeadAttributesString

func (r *Result) HeadAttributesString() string

HeadAttributesString will return the head attributes as a string.

Jump to

Keyboard shortcuts

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