package server import ( lib "git.sr.ht/~cco/go-scopes" "git.sr.ht/~cco/go-scopes/config" "git.sr.ht/~cco/go-scopes/core" "github.com/gin-gonic/gin" ) type Cfg struct { *config.BaseCfg Port string Addr string routes []routeCfg } func (c *Cfg) AddRoute(path string, spec routeSpec, methods ...string) routeSpec { rcfg := routeCfg{ methods: methods, path: path, spec: spec, } if methods == nil { rcfg.methods = []string{"GET"} } c.routes = append(c.routes, rcfg) return spec } type routeCfg struct { methods []string path string spec routeSpec } type routeSpec interface{} type fsSpec struct { docRoot string } func FileServer(docRoot string) routeSpec { return &fsSpec{docRoot} } type RCellSpec struct { lib.Config } func RCellHandler() routeSpec { return &RCellSpec{config.Base("", core.Start)} } type Handler func(lib.Context, *gin.Context)