kama

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

kama

/kam-á/
橘子的臺語
Tangerine in Taiwanese Hokkien

中文版

Kama is a lightweight Go package for building frontend-backend separated web applications.

In development mode, it proxies all unmatched HTTP requests to a frontend dev server (e.g. Vite, Next.js).
In production mode, it serves static files from an embedded filesystem, with optional overrides from a local directory—no recompilation required.

Features

  • Supports both net/http and gin framework
  • Proxies requests to a frontend dev server during development
  • Serves static files via embed.FS in production
  • Allows local static file override on top of embedded files

Installation

go get github.com/simbafs/kama

Quick Overview

//go:embed all:static
var embededFS embed.FS

kama.New(embeddedFS,
  kama.WithDevServer("http://localhost:3001"),
  kama.WithPath("static"),
)

Usage

See the _example/ directory for simple examples. There is a complete example counter

License

MIT

Documentation

Overview

This package provides HTTP server handlers for serving static files. In development mode, it proxies requests to a frontend development server. In production mode, it serves files from the embedded filesystem, with optional overrides from a local directory in the current working directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kama

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

func New

func New(f fs.FS, opts ...KamaOption) *Kama

New creates a new Kama instance

func (*Kama) Gin

func (k *Kama) Gin() gin.HandlerFunc

Gin returns a gin.HandlerFunc for gin

func (*Kama) Go added in v0.2.0

func (k *Kama) Go() http.HandlerFunc

Go returns a http.HandlerFunc for http mux in standard library

type KamaOption

type KamaOption func(*Kama)

func WithDevServer added in v0.4.0

func WithDevServer(devServer string) KamaOption

WithDevServer sets the dev server URL (default is http://localhost:3001)

func WithPath added in v0.4.0

func WithPath(path string) KamaOption

WithPath sets the path to the static directory (default is "static")

func WithTree added in v1.0.0

func WithTree(tree string) KamaOption

WithTree enable a endpoint to show the tree of filesystem

Directories

Path Synopsis
_example
frontend command
gin command
gohttp command

Jump to

Keyboard shortcuts

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