Documentation ¶
Index ¶
- Variables
- func IsIpPrivate(ipAddr string) bool
- func Run(config *Configuration)
- func Validator() *validation.Validator
- type BaseContext
- type BodyFactory
- type ByteCloser
- type ClosableResponse
- type Configuration
- func (c *Configuration) Address(address string) *Configuration
- func (c *Configuration) BodyPool(poolSize int, bufferSize int) *Configuration
- func (c *Configuration) BodyTooLarge(body string) *Configuration
- func (c *Configuration) BodyTooLargeResponse(r Response) *Configuration
- func (c *Configuration) ContextFactory(cf ContextFactory) *Configuration
- func (c *Configuration) Dispatcher(d Dispatcher) *Configuration
- func (c *Configuration) InternalServerError(body string) *Configuration
- func (c *Configuration) InternalServerErrorResponse(r Response) *Configuration
- func (c *Configuration) InvalidFormat(body string) *Configuration
- func (c *Configuration) InvalidFormatResponse(r Response) *Configuration
- func (c *Configuration) InvalidPool(poolSize int, bufferSize int) *Configuration
- func (c *Configuration) LoadRawBody() *Configuration
- func (c *Configuration) NotFound(body string) *Configuration
- func (c *Configuration) NotFoundResponse(r Response) *Configuration
- func (c *Configuration) Route(r *RouteBuilder) *Configuration
- func (c *Configuration) SetGeoIP(path string) *Configuration
- func (c *Configuration) StatsFile(file string) *Configuration
- func (c *Configuration) StatsSleep(sleep time.Duration) *Configuration
- type ContextFactory
- type Dispatcher
- type FatalResponse
- type NormalResponse
- type Params
- type Response
- type ResponseBuilder
- func (b *ResponseBuilder) Cache(duration int) *ResponseBuilder
- func (b *ResponseBuilder) Close() error
- func (b *ResponseBuilder) GetBody() []byte
- func (b *ResponseBuilder) GetHeader() http.Header
- func (b *ResponseBuilder) GetStatus() int
- func (b *ResponseBuilder) Header(key, value string) *ResponseBuilder
- func (b *ResponseBuilder) SetStatus(status int)
- func (b *ResponseBuilder) Status(status int) *ResponseBuilder
- type Route
- type RouteBuilder
- type Router
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NotFound = newNormalResponse([]byte(`{"error":"not found","code":404}`), 404) InternalServerError = newNormalResponse([]byte(`{"error":"internal server error","code":500}`), 500) Deleted = &NormalResponse{204, []byte{}, http.Header{"Content-Length": []string{"0"}}} )
View Source
var (
GeoIP *gi.GeoIP
)
View Source
var (
JsonHeader = []string{"application/json; charset=utf-8"}
)
View Source
var Stats = &stats{}
Functions ¶
func IsIpPrivate ¶
func Run ¶
func Run(config *Configuration)
func Validator ¶
func Validator() *validation.Validator
Types ¶
type BaseContext ¶
type BodyFactory ¶
type BodyFactory func() interface{}
type ByteCloser ¶
type ClosableResponse ¶
type ClosableResponse struct { S int H http.Header B ByteCloser }
func (*ClosableResponse) Close ¶
func (r *ClosableResponse) Close() error
func (*ClosableResponse) GetBody ¶
func (r *ClosableResponse) GetBody() []byte
func (*ClosableResponse) GetHeader ¶
func (r *ClosableResponse) GetHeader() http.Header
func (*ClosableResponse) GetStatus ¶
func (r *ClosableResponse) GetStatus() int
func (*ClosableResponse) Length ¶
func (r *ClosableResponse) Length() int
func (*ClosableResponse) SetStatus ¶
func (r *ClosableResponse) SetStatus(status int)
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
func Configure ¶
func Configure() *Configuration
func (*Configuration) Address ¶
func (c *Configuration) Address(address string) *Configuration
func (*Configuration) BodyPool ¶
func (c *Configuration) BodyPool(poolSize int, bufferSize int) *Configuration
func (*Configuration) BodyTooLarge ¶
func (c *Configuration) BodyTooLarge(body string) *Configuration
func (*Configuration) BodyTooLargeResponse ¶
func (c *Configuration) BodyTooLargeResponse(r Response) *Configuration
func (*Configuration) ContextFactory ¶
func (c *Configuration) ContextFactory(cf ContextFactory) *Configuration
func (*Configuration) Dispatcher ¶
func (c *Configuration) Dispatcher(d Dispatcher) *Configuration
func (*Configuration) InternalServerError ¶
func (c *Configuration) InternalServerError(body string) *Configuration
func (*Configuration) InternalServerErrorResponse ¶
func (c *Configuration) InternalServerErrorResponse(r Response) *Configuration
func (*Configuration) InvalidFormat ¶
func (c *Configuration) InvalidFormat(body string) *Configuration
func (*Configuration) InvalidFormatResponse ¶
func (c *Configuration) InvalidFormatResponse(r Response) *Configuration
func (*Configuration) InvalidPool ¶
func (c *Configuration) InvalidPool(poolSize int, bufferSize int) *Configuration
func (*Configuration) LoadRawBody ¶
func (c *Configuration) LoadRawBody() *Configuration
func (*Configuration) NotFound ¶
func (c *Configuration) NotFound(body string) *Configuration
func (*Configuration) NotFoundResponse ¶
func (c *Configuration) NotFoundResponse(r Response) *Configuration
func (*Configuration) Route ¶
func (c *Configuration) Route(r *RouteBuilder) *Configuration
func (*Configuration) SetGeoIP ¶
func (c *Configuration) SetGeoIP(path string) *Configuration
func (*Configuration) StatsFile ¶
func (c *Configuration) StatsFile(file string) *Configuration
func (*Configuration) StatsSleep ¶
func (c *Configuration) StatsSleep(sleep time.Duration) *Configuration
type ContextFactory ¶
type ContextFactory func(*BaseContext) interface{}
type Dispatcher ¶
type FatalResponse ¶
type FatalResponse struct { Response // contains filtered or unexported fields }
type NormalResponse ¶
func (*NormalResponse) Close ¶
func (r *NormalResponse) Close() error
func (*NormalResponse) GetBody ¶
func (r *NormalResponse) GetBody() []byte
func (*NormalResponse) GetHeader ¶
func (r *NormalResponse) GetHeader() http.Header
func (*NormalResponse) GetStatus ¶
func (r *NormalResponse) GetStatus() int
func (*NormalResponse) SetStatus ¶
func (r *NormalResponse) SetStatus(status int)
type Response ¶
type ResponseBuilder ¶
type ResponseBuilder struct {
Response Response
}
func Json ¶
func Json(body interface{}) *ResponseBuilder
func (*ResponseBuilder) Cache ¶
func (b *ResponseBuilder) Cache(duration int) *ResponseBuilder
func (*ResponseBuilder) Close ¶
func (b *ResponseBuilder) Close() error
func (*ResponseBuilder) GetBody ¶
func (b *ResponseBuilder) GetBody() []byte
func (*ResponseBuilder) GetHeader ¶
func (b *ResponseBuilder) GetHeader() http.Header
func (*ResponseBuilder) GetStatus ¶
func (b *ResponseBuilder) GetStatus() int
func (*ResponseBuilder) Header ¶
func (b *ResponseBuilder) Header(key, value string) *ResponseBuilder
func (*ResponseBuilder) SetStatus ¶
func (b *ResponseBuilder) SetStatus(status int)
func (*ResponseBuilder) Status ¶
func (b *ResponseBuilder) Status(status int) *ResponseBuilder
type Route ¶
type Route struct { Action interface{} BodyFactory BodyFactory }
type RouteBuilder ¶
type RouteBuilder struct {
// contains filtered or unexported fields
}
func R ¶
func R(method, version, resource string, action interface{}) *RouteBuilder
func (*RouteBuilder) BodyFactory ¶
func (r *RouteBuilder) BodyFactory(bf func() interface{}) *RouteBuilder
type Router ¶
type Router struct { *Configuration // contains filtered or unexported fields }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.