fasthttp

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HttpClientIP added in v0.21.0

func HttpClientIP(ctx *fasthttp.RequestCtx) string

ClientIP method returns client IP address from HTTP request.

Note: Set property "app.behind.proxy" to true only if Revel is running behind proxy like nginx, haproxy, apache, etc. Otherwise you may get inaccurate Client IP address. Revel parses the IP address in the order of X-Forwarded-For, X-Real-IP.

By default revel will get http.Request's RemoteAddr.

func NewGracefulListener added in v0.21.0

func NewGracefulListener(ln net.Listener, maxWaitTime time.Duration) net.Listener

NewGracefulListener wraps the given listener into 'graceful shutdown' listener.

Types

type FastHTTPServer

type FastHTTPServer struct {
	Server           *fasthttp.Server    // The server
	ServerInit       *revel.EngineInit   // The server initialization data
	MaxMultipartSize int64               // The max form size
	HttpMuxList      revel.ServerMuxList // The list of muxers
	HasAppMux        bool                // True if has a mux
	// contains filtered or unexported fields
}

The engine.

func (*FastHTTPServer) Engine

func (f *FastHTTPServer) Engine() interface{}

Return the engine.

func (*FastHTTPServer) Event

func (f *FastHTTPServer) Event(event revel.Event, args interface{}) revel.EventResponse

Handle an event generated from Revel.

func (*FastHTTPServer) Init

func (f *FastHTTPServer) Init(init *revel.EngineInit)

Called to initialize the FastHttpServer.

func (*FastHTTPServer) Name

func (f *FastHTTPServer) Name() string

Return the engine name.

func (*FastHTTPServer) RequestHandler

func (f *FastHTTPServer) RequestHandler(ctx *fasthttp.RequestCtx)

The root handler.

func (*FastHTTPServer) Start

func (f *FastHTTPServer) Start()

Handler is assigned in the Init.

func (*FastHTTPServer) Stats

func (f *FastHTTPServer) Stats() map[string]interface{}

Returns stats for the engine.

type FastHttpContext

type FastHttpContext struct {
	Request  *FastHttpRequest  // The request
	Response *FastHttpResponse // The respnse
}

The context.

func NewFastHttpContext

func NewFastHttpContext(instance *FastHTTPServer) *FastHttpContext

Create a new context.

func (*FastHttpContext) Destroy

func (c *FastHttpContext) Destroy()

Called to destroy the context.

func (*FastHttpContext) GetRequest

func (c *FastHttpContext) GetRequest() revel.ServerRequest

Called to get the request.

func (*FastHttpContext) GetResponse

func (c *FastHttpContext) GetResponse() revel.ServerResponse

Called to get the response.

func (*FastHttpContext) SetContext

func (c *FastHttpContext) SetContext(context *fasthttp.RequestCtx)

Called to set the context.

type FastHttpCookie

type FastHttpCookie []byte // The cookie

The cookie.

func (FastHttpCookie) GetValue

func (r FastHttpCookie) GetValue() string

Returns the cookie value.

type FastHttpHeader

type FastHttpHeader struct {
	Source interface{} // The source
	// contains filtered or unexported fields
}

The header.

func (*FastHttpHeader) Add

func (r *FastHttpHeader) Add(key string, value string)

Adds a header key.

func (*FastHttpHeader) Del

func (r *FastHttpHeader) Del(key string)

Deletes a header key.

func (*FastHttpHeader) Get

func (r *FastHttpHeader) Get(key string) (value []string)

returns the header value.

func (*FastHttpHeader) GetCookie

func (r *FastHttpHeader) GetCookie(key string) (value revel.ServerCookie, err error)

Returns a cookie.

func (*FastHttpHeader) GetKeys added in v0.21.0

func (r *FastHttpHeader) GetKeys() (value []string)

Returns the header keys.

func (*FastHttpHeader) Set

func (r *FastHttpHeader) Set(key string, value string)

Sets (replaces) a header key.

func (*FastHttpHeader) SetCookie

func (r *FastHttpHeader) SetCookie(cookie string)

Sets a cookie.

func (*FastHttpHeader) SetStatus

func (r *FastHttpHeader) SetStatus(statusCode int)

Sets the header status.

type FastHttpMultipartForm

type FastHttpMultipartForm struct {
	Form *multipart.Form // The embedded form
}

The form.

func (*FastHttpMultipartForm) GetFiles

func (f *FastHttpMultipartForm) GetFiles() map[string][]*multipart.FileHeader

Returns the files for a form.

func (*FastHttpMultipartForm) GetValues

func (f *FastHttpMultipartForm) GetValues() url.Values

Returns the values for a form.

func (*FastHttpMultipartForm) RemoveAll

func (f *FastHttpMultipartForm) RemoveAll() error

Remove all the vlaues from a form.

type FastHttpRequest

type FastHttpRequest struct {
	Original   *fasthttp.RequestCtx // The original
	FormParsed bool                 // True if the form was parsed

	MultiFormParsed bool // True if multipart form
	// WebSocket       *websocket.Conn // No websocket
	ParsedForm *FastHttpMultipartForm // The parsed form

	Engine *FastHTTPServer // The response header
	// contains filtered or unexported fields
}

The request.

func (*FastHttpRequest) Destroy

func (r *FastHttpRequest) Destroy()

Called when request is done.

func (*FastHttpRequest) Get

func (r *FastHttpRequest) Get(key int) (value interface{}, err error)

Gets the value from the request.

func (*FastHttpRequest) GetForm

func (r *FastHttpRequest) GetForm() (url.Values, error)

Returns the form.

func (*FastHttpRequest) GetHeader

func (r *FastHttpRequest) GetHeader() revel.ServerHeader

Returns the request header.

func (*FastHttpRequest) GetMultipartForm

func (r *FastHttpRequest) GetMultipartForm() (revel.ServerMultipartForm, error)

Returns the form.

func (*FastHttpRequest) GetQuery

func (r *FastHttpRequest) GetQuery() url.Values

Returns the query string.

func (*FastHttpRequest) GetRaw

func (r *FastHttpRequest) GetRaw() interface{}

Returns the raw request.

func (*FastHttpRequest) Set

func (r *FastHttpRequest) Set(key int, value interface{}) bool

Sets the request with the value.

func (*FastHttpRequest) SetContext

func (r *FastHttpRequest) SetContext(req *fasthttp.RequestCtx)

Sets the context.

type FastHttpResponse

type FastHttpResponse struct {
	Original *fasthttp.RequestCtx // The original

	Writer io.Writer       // The writer
	Engine *FastHTTPServer // The engine
	// contains filtered or unexported fields
}

The response.

func (*FastHttpResponse) Destroy

func (r *FastHttpResponse) Destroy()

Called to reset this response.

func (*FastHttpResponse) Get

func (r *FastHttpResponse) Get(key int) (value interface{}, err error)

gets the key from the response.

func (*FastHttpResponse) GetRaw

func (r *FastHttpResponse) GetRaw() interface{}

Returns the raw response.

func (*FastHttpResponse) GetWriter

func (r *FastHttpResponse) GetWriter() io.Writer

Return the response writer.

func (*FastHttpResponse) Header

func (r *FastHttpResponse) Header() revel.ServerHeader

Return the header.

func (*FastHttpResponse) Set

func (r *FastHttpResponse) Set(key int, value interface{}) (set bool)

Sets the key with the value.

func (*FastHttpResponse) SetContext

func (r *FastHttpResponse) SetContext(w *fasthttp.RequestCtx)

Sets the context.

func (*FastHttpResponse) SetWriter

func (r *FastHttpResponse) SetWriter(writer io.Writer)

Sets the writer.

func (*FastHttpResponse) WriteStream

func (r *FastHttpResponse) WriteStream(name string, contentlen int64, modtime time.Time, reader io.Reader) error

Writes a stream to the response.

type GracefulListener added in v0.21.0

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

func (*GracefulListener) Accept added in v0.21.0

func (ln *GracefulListener) Accept() (net.Conn, error)

func (*GracefulListener) Addr added in v0.21.0

func (ln *GracefulListener) Addr() net.Addr

func (*GracefulListener) Close added in v0.21.0

func (ln *GracefulListener) Close() error

Close closes the inner listener and waits until all the pending open connections are closed before returning.

Jump to

Keyboard shortcuts

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