Documentation
¶
Index ¶
- func UseLog(_log *logrus.Logger)
- type PageTemplate
- type Server
- func (s *Server) File(w http.ResponseWriter, r *http.Request)
- func (s *Server) FileList(w http.ResponseWriter, r *http.Request)
- func (s *Server) Shutdown() error
- func (s *Server) Token(w http.ResponseWriter, r *http.Request)
- func (s *Server) UIDToFilePath(UID string, mkdir bool) (string, int, error)
- func (s *Server) UploadFile(w http.ResponseWriter, r *http.Request)
- func (s *Server) WithJWTCookie(next http.Handler) http.Handler
- func (s *Server) WithSession(next http.Handler) http.Handler
- func (s *Server) WithUserFileAuthz(next http.Handler) http.Handler
- type SiteTemplates
- type UserFileStoreItem
- type WebMux
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PageTemplate ¶
type PageTemplate struct {
// contains filtered or unexported fields
}
PageTemplate associates a template file with an http/template.Template
type Server ¶
type Server struct { CookieStore *sessions.FilesystemStore AuthToken *jwtauth.JWTAuth SigningKey string MaxFileSize int64 FilesPath string Templates *SiteTemplates UserFileStore *storm.DB }
Server manages cookies/auth, and implements the http handlers
func NewServer ¶
NewServer creates a new Server for the given signing secret, cookie storage file system path, and uploaded file size limit.
func (*Server) File ¶
func (s *Server) File(w http.ResponseWriter, r *http.Request)
File is the handler for file downloads, requiring the "{fileid}" URL path parameter (e.g. /file/{fileid}).
func (*Server) FileList ¶
func (s *Server) FileList(w http.ResponseWriter, r *http.Request)
FileList generates a response containing a JSON array of file UIDs that the user is permitted to access.
func (*Server) Token ¶
func (s *Server) Token(w http.ResponseWriter, r *http.Request)
Token returns the user/session's current JWT.
func (*Server) UIDToFilePath ¶
UIDToFilePath looks up the file name for the file with unique identifier UID, and returns the absolute path to the files, a http status code, and an error.
func (*Server) UploadFile ¶
func (s *Server) UploadFile(w http.ResponseWriter, r *http.Request)
UploadFile is the upload handler for POST requests with the file data stored in the body with Content-Type multipart/form-data.
func (*Server) WithJWTCookie ¶
WithJWTCookie injects a new or existing cookie-managed JWT into the request context. The signed token and the session are both embedded.
func (*Server) WithSession ¶
WithSession injects a new or existing cookie-managed session into the request context.
type SiteTemplates ¶
type SiteTemplates struct {
// contains filtered or unexported fields
}
SiteTemplates contains all of the PageTemplates used by webfiles, as well as the template.FuncMap used in their execution.
func NewTemplates ¶
NewTemplates parses all of the named templates in the given folder. The file names are obtained by concatenating ".tmpl" to the tamplate name.
func (*SiteTemplates) ExecTemplate ¶
func (t *SiteTemplates) ExecTemplate(w http.ResponseWriter, name string, data interface{}) error
ExecTemplate executes the specified template using the supplied data, and writes the result directly to the ResponseWriter.
func (*SiteTemplates) ExecTemplateToString ¶
func (t *SiteTemplates) ExecTemplateToString(name string, data interface{}) (string, error)
ExecTemplateToString executes the specified template using the supplied data, and writes the result into a string. If the template fails to execute or isn't found, a non-nil error will be returned.
type UserFileStoreItem ¶
type UserFileStoreItem struct { RowID int `storm:"id,increment"` User string `storm:"index"` FileID int64 `storm:"index"` }
UserFileStoreItem is the type in the storm user-file DB.