http

package
v0.0.0-...-54fa1f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2014 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Overview

Package htto implements a simple and userful http framwork

Index

Constants

View Source
const (
	// Go on exe
	PASS = iota //b=0
	// Stop
	STOP //c=1
)

Variables

View Source
var Sessions *session.Manager

Just a beego session manager

Functions

func InitDefaultSessions

func InitDefaultSessions()

Initialization the session manager

func Run

func Run(addr string)

Types

type Context

type Context struct {
	Out *Writer
	In  *Reader

	ResponseWriter http.ResponseWriter
	Request        *http.Request
	// contains filtered or unexported fields
}

func NewContext

func NewContext(w http.ResponseWriter, r *http.Request) *Context

New a Context

func NewContext(w http.ResponseWriter, r *http.Request, sess session.SessionStore) *Context {
	return &Context{
		sess:           sess,
		ResponseWriter: w,
		Request:        r,
	}
}

func (*Context) GetForm

func (cxt *Context) GetForm(key string) string

Get form

func (*Context) GetSess

func (cxt *Context) GetSess() session.SessionStore

Get the request's session

func (*Context) Redirect

func (ctx *Context) Redirect(status int, localurl string)

Redirect does redirection to localurl with http header status code. It sends http response header directly.

func (*Context) WriteString

func (cxt *Context) WriteString(s string) (int, error)

Write a string

type Controller

type Controller struct {
	// A connection context
	Ctx *Context
}

func (*Controller) Delete

func (c *Controller) Delete()

Delete adds a request function to handle DELETE request.

func (*Controller) Get

func (c *Controller) Get()

func (*Controller) Head

func (c *Controller) Head()

Head adds a request function to handle HEAD request.

func (*Controller) Options

func (c *Controller) Options()

Options adds a request function to handle OPTIONS request.

func (*Controller) Patch

func (c *Controller) Patch()

Patch adds a request function to handle PATCH request.

func (*Controller) Post

func (c *Controller) Post()

Post adds a request function to handle POST request.

func (*Controller) Prepare

func (c *Controller) Prepare() int

func (*Controller) Put

func (c *Controller) Put()

Put adds a request function to handle PUT request.

func (*Controller) Set

func (c *Controller) Set(ctx *Context)
func NewController(w http.ResponseWriter, r *http.Request, sess session.SessionStore) *Controller {
	return &Controller{
		Ctx: NewContext(w, r, sess),
	}
}

type ControllerInterface

type ControllerInterface interface {
	Get()
	Post()
	Delete()
	Put()
	Head()
	Patch()
	Options()

	Set(ctx *Context)
	Prepare() int
	// contains filtered or unexported methods
}

type DefaultMux

type DefaultMux struct {
	// All routes
	Routes     map[string]ControllerInterface
	FileRoutes map[string]ControllerInterface
}
var Mux *DefaultMux

A defaultmux user the go net ctrollor

func NewDefaultMux

func NewDefaultMux() *DefaultMux

func (*DefaultMux) Add

func (mux *DefaultMux) Add(match string, c ControllerInterface)

Add a router (warnning you can't use match("/") as the route)

func (*DefaultMux) AddGroup

func (mux *DefaultMux) AddGroup(match string, group *MuxGroup)

Add a group(include his members).

func (*DefaultMux) ServeHTTP

func (mux *DefaultMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

Implements the handler

type MuxGroup

type MuxGroup struct {
	// contains filtered or unexported fields
}

A Group e.g. "/admin/login", "/admin/info" all belong to "/admin" group

func NewMuxGroup

func NewMuxGroup() *MuxGroup

func (*MuxGroup) Add

func (mux *MuxGroup) Add(match string, c ControllerInterface)

Add the group's member

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

The Reader implements ReaderCloser interface

func NewReader

func NewReader(body io.ReadCloser, encode string) *Reader

func (*Reader) Close

func (this *Reader) Close() error

func (*Reader) Read

func (this *Reader) Read(data []byte) (n int, err error)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Filter

func NewWriter

func NewWriter(w io.Writer, encode string) *Writer

func (*Writer) Write

func (this *Writer) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL