Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdata committed Dec 18, 2024
1 parent 410049e commit 1135e51
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
25 changes: 25 additions & 0 deletions jawsboot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# jawsboot

Provides a statically served and embedded version of [Bootstrap](https://getbootstrap.com/).

Example usage that loads your templates, favicon and Bootstrap. Also uses the templatereloader
so that when running with `-tags debug` or `-race` templates are reloaded from disk as needed.

```go
//go:embed assets
var assetsFS embed.FS

func setupRoutes(jw *jaws.Jaws, mux *http.ServeMux) (err error) {
var tmpl jaws.TemplateLookuper
if tmpl, err = templatereloader.New(assetsFS, "assets/ui/*.html", ""); err == nil {
jw.AddTemplateLookuper(tmpl)
var faviconuri string
if faviconuri, err = staticserve.HandleFS(assetsFS, "assets", "static/images/favicon.png", mux.Handle); err == nil {
if err = jawsboot.Setup(jw, mux.Handle, faviconuri); err == nil {
// set up your other routes
}
}
}
return
}
```
6 changes: 6 additions & 0 deletions staticserve/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# staticserve

`staticserve` is a cache-busting HTTP handler for static files. It supports
GET operations requesting the file with no encoding or gzip encoding.

For an example how to use it, see `jawsboot/README.md`.
6 changes: 3 additions & 3 deletions staticserve/staticserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
)

type StaticServe struct {
Name string
ContentType string
Gz []byte
Name string // the cache-busting file name, e.g. "static/filename.1234567.js"
ContentType string // Content-Type of the file, e.g. "application/javascript"
Gz []byte // gzipped data, will be unpacked as needed
}

// New returns a StaticServe that serves the given data with a filename like 'filename.12345678.ext'.
Expand Down
7 changes: 7 additions & 0 deletions templatereloader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# templatereloader

A templatereloader is a `jaws.TemplateLookuper` that will reload templates from
disk as needed if running with `-tags debug` or `-race`. If not, it simply calls
`template.New("").ParseFS(fsys, fpath)` and has no overhead.

For example usage, see `jawsboot/README.md`

0 comments on commit 1135e51

Please sign in to comment.