Documentation
¶
Index ¶
- Variables
- func AccessAdapter(config string) func(http.Handler) http.Handler
- func CreateUploadDir()
- func DeleteUserCookie(w http.ResponseWriter)
- func GetACL(user string, srv *Server) string
- func GlobalContext(srv *Server)
- type Request
- type Server
- func (srv *Server) DynamicHandler(fs *fn.FNode) http.HandlerFunc
- func (srv *Server) InitSessions()
- func (srv *Server) LoginAdapter(userdb string) func(http.Handler) http.Handler
- func (srv *Server) Serve(timeout int, router http.Handler)
- func (srv *Server) Shutdown()
- func (srv *Server) StaticFileHandler(protect bool, fs *fn.FNode) http.HandlerFunc
- func (srv *Server) UserCookie() *securecookie.Obj
- func (srv *Server) UserCookieValue(r *http.Request) string
- func (srv *Server) WatchContext(path string)
Constants ¶
This section is empty.
Variables ¶
var TplExtensions []string = []string{".htm", ".txt", ".csv", ".json", ".g", ".ogdl", ".xml", ".xlsx", ".svg"}
Functions ¶
func CreateUploadDir ¶
func CreateUploadDir()
func DeleteUserCookie ¶
func DeleteUserCookie(w http.ResponseWriter)
func GlobalContext ¶
func GlobalContext(srv *Server)
GlobalContext loads the context for template processing
Types ¶
type Request ¶
type Request struct {
HttpRequest *http.Request
User string
Context *ogdl.Graph
Path string
File *fn.FNode
Mime string
}
func ConvertRequest ¶
type Server ¶
type Server struct {
Host string
Hosts []string
Config *ogdl.Graph
HostContexts map[string]*ogdl.Graph
Context *ogdl.Graph
Root *fn.FNode
DocRoot string
UploadDir string
DefaultUser string
UserDb *sql.DB
MaxSessions int
Multi bool
Templates map[string]*ogdl.Graph
ContextMu sync.RWMutex
Secret []byte // Used as key for encoding persistent user cookies
// contains filtered or unexported fields
}
func NewMulti ¶
NewMulti prepares a Server for virtual-host mode. Each subdirectory that looks like a hostname gets its own context loaded from <host>/.conf/context.ogdl.
func (*Server) DynamicHandler ¶
func (srv *Server) DynamicHandler(fs *fn.FNode) http.HandlerFunc
DynamicHandler returns a handler that processes dynamic (template/data) requests.
If fs is non-nil it is tried first; on miss the handler falls back to srv.Root. If fs is nil, srv.Root is used and path-level auth is enforced via checkPath.
func (*Server) InitSessions ¶
func (srv *Server) InitSessions()
func (*Server) LoginAdapter ¶
LoginAdapter handles "Login" and "Logout"
Login: sets r.Form["user"] to the authenticated user name. Logout: removes the session Other: do nothing
func (*Server) StaticFileHandler ¶
StaticFileHandler returns a handler that serves static files.
If protect is true, an authenticated user is required. If fs is non-nil it is used as the file tree; otherwise srv.Root is used. In multi-host mode (srv.Multi) the hostname is prepended to the path.
func (*Server) UserCookie ¶
func (srv *Server) UserCookie() *securecookie.Obj
func (*Server) WatchContext ¶
WatchContext watches the given context.ogdl file and reloads srv.Context whenever the file is written or replaced. Intended to be run as a goroutine.