server

package
v0.0.0-...-c592df2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2016 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OPTIONS = "OPTIONS"
	GET     = "GET"
	HEAD    = "HEAD"
	POST    = "POST"
	PUT     = "PUT"
	DELETE  = "DELETE"
	TRACE   = "TRACE"
	CONNECT = "CONNECT"
	PATCH   = "PATCH"
)

HTTP Methods

View Source
const (
	Accept            = "Accept"
	AcceptCharset     = "Accept-Charset"
	AcceptEncoding    = "Accept-Encoding"
	AcceptLanguage    = "Accept-Language"
	AcceptRanges      = "Accept-Ranges"
	Allow             = "Allow"
	Authorization     = "Authorization"
	CacheControl      = "Cache-Control"
	Connection        = "Connection"
	ContentEncoding   = "Content-Encoding"
	ContentLanguage   = "Content-Language"
	ContentLength     = "Content-Length"
	ContentLocation   = "Content-Location"
	ContentMD5        = "Content-Md5"
	ContentRange      = "Content-Range"
	ContentType       = "Content-Type"
	Date              = "Date"
	ETag              = "Etag"
	Expect            = "Expect"
	Expires           = "Expires"
	Forwarded         = "Forwarded"
	Host              = "Host"
	IfMatch           = "If-Match"
	IfModifiedSince   = "If-Modified-Since"
	IfNoneMatch       = "If-None-Match"
	IfRange           = "If-Range"
	IfUnmodifiedSince = "If-Unmodified-Since"
	LastModified      = "Last-Modified"
	Location          = "Location"
	Referer           = "Referer" // sic
	RetryAfter        = "Retry-After"
	Server            = "Server"
	TE                = "TE"
	Trailer           = "Trailer"
	TransferEncoding  = "Transfer-Encoding"
	Upgrade           = "Upgrade"
	UserAgent         = "User-Agent"
	Vary              = "Vary"
	Via               = "Via"
	Warning           = "Warning"
	XForwardedFor     = "X-Forwarded-For"
	XForwardedHost    = "X-Forwarded-Host"
	XForwardedProto   = "X-Forwarded-Proto"
)

HTTP Headers

View Source
const (
	CacheControlNoCache = "no-cache"
	CacheControlPrivate = "private, max-age=86400"
	CacheControlPublic  = "public, max-age=86400"
)

Values for the HTTP "Cache-Control" Header

View Source
const (
	MediaTypeJS      = "application/javascript"
	MediaTypeJSON    = "application/json"
	MediaTypeWwwForm = "application/x-www-form-urlencoded"
	MediaTypeXML     = "application/xml"

	MediaTypeCSS  = "text/css; charset=utf-8"
	MediaTypeHTML = "text/html; charset=utf-8"
	MediaTypeText = "text/plain; charset=utf-8"

	MediaTypeGIF  = "image/gif"
	MediaTypeICO  = "image/x-icon"
	MediaTypeJPEG = "image/jpeg"
	MediaTypePNG  = "image/png"

	MediaTypeBinary = "application/octet-stream"
)

Values for the HTTP "Content-Type" Header

Variables

View Source
var StaticHandlers []*StaticHandler

Functions

func AllowMethods

func AllowMethods(w http.ResponseWriter, r *http.Request, methods ...string) bool

func ETagFor

func ETagFor(data []byte) string

func GetJSONBody

func GetJSONBody(w http.ResponseWriter, r *http.Request, v interface{}) bool

func IsContentType

func IsContentType(r *http.Request, t string) bool

func Must

func Must(err error)

func MustMarshalJSON

func MustMarshalJSON(v interface{}) []byte

func MustMarshalProto

func MustMarshalProto(v proto.Message) []byte

func MustUnmarshalJSON

func MustUnmarshalJSON(raw []byte, v interface{})

func MustUnmarshalProto

func MustUnmarshalProto(raw []byte, v proto.Message)

func RenderHTML

func RenderHTML(w http.ResponseWriter, r *http.Request, name string, page *Page, cacheCtrl string)

Types

type BlobHandler

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

func (BlobHandler) CreateBlob

func (h BlobHandler) CreateBlob(w http.ResponseWriter, r *http.Request)

func (BlobHandler) GetBlob

func (h BlobHandler) GetBlob(w http.ResponseWriter, r *http.Request, blobId uint64)

func (BlobHandler) ListBlobs

func (h BlobHandler) ListBlobs(w http.ResponseWriter, r *http.Request)

func (BlobHandler) ServeHTTP

func (h BlobHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type BlobReference

type BlobReference struct {
	Id uint64 `json:"id"`
}

type CloudServer

type CloudServer struct {
	Repo *repo.Repo
	// contains filtered or unexported fields
}

func New

func New(dir string) (*CloudServer, error)

func (*CloudServer) Close

func (srv *CloudServer) Close() error

func (*CloudServer) ListenAndServe

func (srv *CloudServer) ListenAndServe(proto, laddr string) error

func (*CloudServer) Serve

func (srv *CloudServer) Serve(l net.Listener) error

func (*CloudServer) Stop

func (srv *CloudServer) Stop()

type Group

type Group struct {
	Id          uint64   `protobuf:"varint,1,opt,name=id" json:"id,omitempty"`
	GroupName   string   `protobuf:"bytes,2,opt,name=group_name" json:"group_name,omitempty"`
	Description string   `protobuf:"bytes,3,opt,name=description" json:"description,omitempty"`
	Users       []uint64 `protobuf:"varint,4,rep,name=users" json:"users,omitempty"`
}

func (*Group) ProtoMessage

func (*Group) ProtoMessage()

func (*Group) Reset

func (m *Group) Reset()

func (*Group) String

func (m *Group) String() string

type GroupDelta

type GroupDelta struct {
	GroupName   *string   `json:"group_name"`
	Description *string   `json:"description"`
	Users       *[]uint64 `json:"users"`
}

func (*GroupDelta) Apply

func (d *GroupDelta) Apply(g *Group)

func (*GroupDelta) Validate

func (d *GroupDelta) Validate(lifetime GroupLifetime) error

type GroupHandler

type GroupHandler struct{ Repo *repo.Repo }

func (GroupHandler) CreateGroup

func (h GroupHandler) CreateGroup(w http.ResponseWriter, r *http.Request)

func (GroupHandler) DeleteGroup

func (h GroupHandler) DeleteGroup(w http.ResponseWriter, r *http.Request, groupId uint64, groupName string)

func (GroupHandler) GetGroup

func (h GroupHandler) GetGroup(w http.ResponseWriter, r *http.Request, groupId uint64, groupName string)

func (GroupHandler) ListGroups

func (h GroupHandler) ListGroups(w http.ResponseWriter, r *http.Request)

func (GroupHandler) PutGroup

func (h GroupHandler) PutGroup(w http.ResponseWriter, r *http.Request, groupId uint64, groupName string)

func (GroupHandler) ServeHTTP

func (h GroupHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GroupLifetime

type GroupLifetime bool
const (
	NewGroup      GroupLifetime = false
	ExistingGroup GroupLifetime = true
)

type HomeHandler

type HomeHandler struct{}

func (HomeHandler) ServeHTTP

func (h HomeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type KeepAliveListener

type KeepAliveListener struct{ L net.Listener }

func (KeepAliveListener) Accept

func (l KeepAliveListener) Accept() (net.Conn, error)

func (KeepAliveListener) Addr

func (l KeepAliveListener) Addr() net.Addr

func (KeepAliveListener) Close

func (l KeepAliveListener) Close() error

type Page

type Page struct{}

type StaticHandler

type StaticHandler struct {
	Path     string
	MimeType string
	ETag     string
	Data     []byte
}

func (*StaticHandler) ServeHTTP

func (h *StaticHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type UnproxyHandler

type UnproxyHandler struct{ H http.Handler }

func (UnproxyHandler) ServeHTTP

func (handler UnproxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type User

type User struct {
	Id          uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"`
	UserName    string `protobuf:"bytes,2,opt,name=user_name" json:"user_name,omitempty"`
	DisplayName string `protobuf:"bytes,3,opt,name=display_name" json:"display_name,omitempty"`
	EMail       string `protobuf:"bytes,4,opt,name=email" json:"email,omitempty"`
	URL         string `protobuf:"bytes,5,opt,name=url" json:"url,omitempty"`
}

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) Reset

func (m *User) Reset()

func (*User) String

func (m *User) String() string

type UserDelta

type UserDelta struct {
	UserName    *string `json:"user_name"`
	DisplayName *string `json:"display_name"`
	EMail       *string `json:"email"`
	URL         *string `json:"url"`
}

func (*UserDelta) Apply

func (d *UserDelta) Apply(u *User)

func (*UserDelta) Validate

func (d *UserDelta) Validate(lifetime UserLifetime) error

type UserHandler

type UserHandler struct{ Repo *repo.Repo }

func (UserHandler) CreateUser

func (h UserHandler) CreateUser(w http.ResponseWriter, r *http.Request)

func (UserHandler) DeleteUser

func (h UserHandler) DeleteUser(w http.ResponseWriter, r *http.Request, userId uint64, userName string)

func (UserHandler) GetUser

func (h UserHandler) GetUser(w http.ResponseWriter, r *http.Request, userId uint64, userName string)

func (UserHandler) ListUsers

func (h UserHandler) ListUsers(w http.ResponseWriter, r *http.Request)

func (UserHandler) PutUser

func (h UserHandler) PutUser(w http.ResponseWriter, r *http.Request, userId uint64, userName string)

func (UserHandler) ServeHTTP

func (h UserHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type UserLifetime

type UserLifetime bool
const (
	NewUser      UserLifetime = false
	ExistingUser UserLifetime = true
)

Jump to

Keyboard shortcuts

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