Documentation ¶
Index ¶
- Variables
- type Config
- type Server
- func (s *Server) Config() *Config
- func (s *Server) DecodeForm(v interface{}, r *http.Request) error
- func (s *Server) Decoder() *form.Decoder
- func (s *Server) HTML(w io.Writer, file string, ctx pongo2.Context) error
- func (s *Server) Router() *chi.Mux
- func (s *Server) Start() error
- func (s *Server) Template() *pongo2.TemplateSet
Constants ¶
This section is empty.
Variables ¶
var DefaultMiddleware = []func(http.Handler) http.Handler{ middleware.Logger, middleware.Recoverer, middleware.DefaultCompress, middleware.RedirectSlashes, }
DefaultMiddleware is an array of basic middleware that are likely to be used in most applications.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { IP string // IP address to listen on. If blank listen on any Port int // Port number to listen on. If blank it's dynamic? AutoTLS bool // Setup TLS automatically using let's encrypt AutoTLSDomains []string // The acceptable domains for let's encrypt certs PublicDir string // The path to the public directory Secret string // The secret for secure cookies and CSRF TemplateDir string // The location of template files CacheTemplates bool // If true templates are cached which is faster in production UseDefaultMiddleware bool // If true the default middleware is loaded Database string // mysql or sqlite3 DatabaseDSN string // The Database DSN. For example: file:test.db?_fk=1 }
Config holds all of the possible variables for configuring a web server
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig returns a very basic configuration that might be ok for development but is not usable for most production deployments.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds the various components needed for a web server
func NewServer ¶
NewServer initializes a new Server struct based on the Config that is passed in. If Config is nil then the Config returned by NewDefaultConfig is used.
func (*Server) DecodeForm ¶ added in v0.1.4
DecodeForm taks a value and a *http.Request, parses the form and tries to populate the form values into v.
func (*Server) Decoder ¶
Decoder returns the decoder used for forms. This can be used to add custom behavior. In common cases it shouldn't be needed.
func (*Server) HTML ¶ added in v0.1.2
HTML renders the template and writes the response to the client. In this case file will be relative to the templates directory. For example if you have a template like templates/users/new.html you can pass users/new.html as the file.
func (*Server) Template ¶
func (s *Server) Template() *pongo2.TemplateSet
Template returns the template engine used for this server.