Documentation ¶
Index ¶
- func GenerateId() string
- type App
- func (app *App) Delete(url string, handler handlerFunc)
- func (app *App) Get(url string, handler handlerFunc)
- func (app *App) Listen(serverURL string)
- func (app *App) NotFound(handler handlerFunc)
- func (app *App) Post(url string, handler handlerFunc)
- func (app *App) Put(url string, handler handlerFunc)
- func (app *App) Settings(settings *Settings)
- func (app *App) Static(url string)
- func (app *App) Use(handler handlerFunc)
- type Request
- type Response
- func (res *Response) Json(model interface{})
- func (res *Response) Redirect(url string)
- func (res *Response) Render(viewName string, model interface{})
- func (res *Response) RenderTemplate(templateName string, model interface{})
- func (res *Response) Send(str string)
- func (res *Response) SetCookie(cookie *http.Cookie)
- func (res *Response) WriteHeader(code int)
- type Session
- type SessionManager
- type SessionStore
- type Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App represents you web application, which has a settings and handlers.
func NewApp ¶
func NewApp() App
NewApp creates a new instance of App. It uses default settings for application. Settings can be updated using Settings method.
func (*App) Listen ¶
Listen listens on the TCP network address and then calls handler corresponding the request url to handle requests on incoming connections.
func (*App) NotFound ¶
func (app *App) NotFound(handler handlerFunc)
NotFound overrides 404 status result. It will be called when no routes match request url.
type Request ¶
type Request struct { *http.Request // RouteParams is key-value pairs of route parameters. // If you route is "/category/{id}" and request url is "/category/1", // RouteParams will contain "id" => "1". RouteParams map[string]string // Session have a session data for current user. Session *Session }
Request contains current request data.
type Response ¶
Response sends data to the client.
func (*Response) Render ¶
Render parse given html using model and send to response. It use html/template to parse html
func (*Response) RenderTemplate ¶
RenderTemplate parse given template by name using model and send to response. Template should be defined as {{ define "name" }} ... {{ end }}.
func (*Response) WriteHeader ¶
WriteHeader sends an HTTP response header with status code.
type Session ¶
type Session struct { Id string Value interface{} Expires time.Time // contains filtered or unexported fields }
Session represents current session and its data.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manage session for current request.
func NewSessionManager ¶
func NewSessionManager(store SessionStore, timeout time.Duration) *SessionManager
NewSessionManager creates new instance of SessionManager.
func (*SessionManager) GetSession ¶
func (manager *SessionManager) GetSession(req *Request, res *Response) *Session
GetSession returns session for current request. If there is no session, it will be created.
type SessionStore ¶
type SessionStore interface { Get(id string) *Session New(id string, session *Session) Delete(id string) }
SessionStore is an interface which allow to implement custom session store.
type Settings ¶
type Settings struct { // Path to the root folder with html files. ViewsPath string // Path to the root folder with static content (js, css, images). StaticPath string // Extension of the View files or templates. ViewExtension string }
Settings represent application settings.
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings creates a settings object with default settings.