Documentation
¶
Index ¶
- Constants
- Variables
- func Black(s string) string
- func Blue(s string) string
- func BuildChain(f http.HandlerFunc, m ...Middleware) http.HandlerFunc
- func CopyDir(dst, src string) error
- func Cyan(s string) string
- func FileExists(filename string) bool
- func Green(s string) string
- func InjectVarsIntoIndex(indexFile []byte, entryFileName, assetsDir, publicUrl string) ([]byte, bool)
- func IsFlagPassed(name string) bool
- func Magenta(s string) string
- func ParseBrowserTarget(customBrowserTarget string) (api.Target, error)
- func ParseLoader(text string) (api.Loader, error)
- func ParseVersion() string
- func PipedFileServer(baseDir string, pipe http.HandlerFunc) http.HandlerFunc
- func PipedFileServerWithMiddleware(baseDir string, pipe http.HandlerFunc, ...) http.HandlerFunc
- func Print(a ...any)
- func PrintError(a ...any)
- func PrintErrorf(format string, a ...any)
- func PrintInfo(a ...any)
- func PrintInfof(format string, a ...any)
- func PrintItem(a ...any)
- func PrintItemf(format string, a ...any)
- func PrintOk(a ...any)
- func PrintOkf(format string, a ...any)
- func PrintReload(a ...any)
- func PrintReloadf(format string, a ...any)
- func PrintWarn(a ...any)
- func PrintWarnf(format string, a ...any)
- func Printe(a ...any)
- func Printef(format string, a ...any)
- func Printf(format string, a ...any)
- func RealQuickPath(fpath string) string
- func Realpath(fpath string) (string, error)
- func Red(s string) string
- func StringifyLoader(loader api.Loader) (string, error)
- func UseColor(use bool)
- func White(s string) string
- func WrappedFileServer(baseDir string) http.HandlerFunc
- func Yellow(s string) string
- type ArrayFlags
- type Broker
- type Config
- type LoaderFlags
- type MapFlags
- type Middleware
- type NotFoundRedirectRespWr
- type PackageJson
Constants ¶
const ( ColorBlack = "\033[0;30m" ColorRed = "\033[0;31m" ColorGreen = "\033[0;32m" ColorYellow = "\033[0;33m" ColorBlue = "\033[0;34m" ColorMagenta = "\033[0;35m" ColortCyan = "\033[0;36m" ColortWhite = "\033[0;37m" ColorClear = "\033[0m" )
Variables ¶
var DASH = "–"
var ERR = "× ERR:"
var INFO = ">"
var ITEM = "-"
var OK = "✓"
var RELOAD = "↻"
var Version = "dev"
Version will contain nrb build number on build
var WARN = "⚠"
Functions ¶
func BuildChain ¶
func BuildChain(f http.HandlerFunc, m ...Middleware) http.HandlerFunc
BuildChain builds the middlware chain recursively, functions are first class
func InjectVarsIntoIndex ¶
func InjectVarsIntoIndex(indexFile []byte, entryFileName, assetsDir, publicUrl string) ([]byte, bool)
InjectVarsIntoIndex injects js/css import to index.html content, returns bool if injected into content
func IsFlagPassed ¶
func ParseVersion ¶ added in v0.1.8
func ParseVersion() string
ParseVersion will use git to get current revision to use as version string
func PipedFileServer ¶
func PipedFileServer(baseDir string, pipe http.HandlerFunc) http.HandlerFunc
PipedFileServer wraps your http.FileServer with neutered fs to remove dir browsing and pipes 404 to next handler
func PipedFileServerWithMiddleware ¶
func PipedFileServerWithMiddleware(baseDir string, pipe http.HandlerFunc, middleware func(next http.HandlerFunc) http.HandlerFunc) http.HandlerFunc
PipedFileServerWithMiddleware wraps PipedFileServer with middleware
func PrintError ¶
func PrintError(a ...any)
func PrintErrorf ¶
func PrintInfof ¶
func PrintItemf ¶
func PrintReload ¶
func PrintReload(a ...any)
func PrintReloadf ¶
func PrintWarnf ¶
func RealQuickPath ¶
RealQuickPath just quickly gets path, without caring about errors
func WrappedFileServer ¶
func WrappedFileServer(baseDir string) http.HandlerFunc
WrappedFileServer wraps your http.FileServer with neutered fs to remove dir browsing and redirects 404 to index.html
Types ¶
type ArrayFlags ¶ added in v0.1.8
type ArrayFlags []string
func (*ArrayFlags) Set ¶ added in v0.1.8
func (i *ArrayFlags) Set(value string) error
func (*ArrayFlags) String ¶ added in v0.1.8
func (i *ArrayFlags) String() string
type Broker ¶
type Broker struct {
// Events are pushed to this channel by the main events-gathering routine
Notifier chan []byte
// contains filtered or unexported fields
}
A Broker holds open client connections, listens for incoming events on its Notifier channel and broadcast event data to all registered connections
func NewStreamServer ¶
func NewStreamServer() (broker *Broker)
type Config ¶ added in v0.1.8
type Config struct {
AliasPackages MapFlags
ResolveModules MapFlags
PreloadPathsStartingWith ArrayFlags
Injects ArrayFlags
InlineSize int64
InlineExtensions []string
Loaders LoaderFlags
Splitting bool
}
func ParseJsonConfig ¶ added in v0.1.8
func ParseJsonConfig(packageJson PackageJson) (*Config, error)
type LoaderFlags ¶ added in v0.1.8
func (*LoaderFlags) Set ¶ added in v0.1.8
func (i *LoaderFlags) Set(value string) error
func (*LoaderFlags) String ¶ added in v0.1.8
func (i *LoaderFlags) String() string
type Middleware ¶
type Middleware func(http.HandlerFunc) http.HandlerFunc
Middleware is a definition of what a middleware is, take in one handlerfunc and wrap it within another handlerfunc
type NotFoundRedirectRespWr ¶
type NotFoundRedirectRespWr struct {
http.ResponseWriter // We embed http.ResponseWriter
// contains filtered or unexported fields
}
NotFoundRedirectRespWr response for neutered fs
func (*NotFoundRedirectRespWr) Write ¶
func (w *NotFoundRedirectRespWr) Write(p []byte) (int, error)
func (*NotFoundRedirectRespWr) WriteHeader ¶
func (w *NotFoundRedirectRespWr) WriteHeader(status int)
type PackageJson ¶ added in v0.1.8
func ParsePackageJson ¶ added in v0.1.8
func ParsePackageJson(packagePath string) (PackageJson, error)