goexpress

package module
v0.0.0-...-db28aac Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host         string
	Port         int
	ReuseConn    bool
	MaxReuseConn int
	Cache        bool
	CacheMaxAge  int
}

Config type

type Cookie struct {
	Name     string
	Value    string
	Path     string
	Domain   string
	Expires  time.Time
	MaxAge   string
	Secure   bool
	HTTPOnly bool
}

Cookie type

func (*Cookie) String

func (c *Cookie) String() string

Cookie.String() returns a string, put it to Set-Cookie header

type Request

type Request struct {
	Type    string
	Path    string
	Proto   string
	Headers map[string]string
	Body    map[string]string
	Params  map[interface{}]interface{}
}

Request type

type Response

type Response struct {
	Proto      string
	Statuscode int
	Statusmsg  string
	Headers    map[string]string

	status.Status
	// contains filtered or unexported fields
}

Response type

func (*Response) DelCookie

func (res *Response) DelCookie(name string)

DelCookie (name string) immediately deletes cookie

func (*Response) Error

func (res *Response) Error(status [3]string)

Error (status []string) sends response with error to client

func (*Response) Header

func (res *Response) Header(key string, value string)

Header (key string, value string) sets header with given name and value

func (*Response) Redirect

func (res *Response) Redirect(to string)

Redirect (to string) redirect user to given path

func (*Response) Send

func (res *Response) Send(body string)

Send (body string) sends data to client

func (*Response) SendFile

func (res *Response) SendFile(path string) error

SendFile (path string) (error) sends file to client

func (*Response) SetCookie

func (res *Response) SetCookie(c *Cookie)

SetCookie (c *Cookie) sets cookie, it takes data from cookie object

type Server

type Server struct {
	Host       string
	Port       int
	Socket     net.Listener
	STATIC     map[string]string
	Middleware []func(req *Request, res *Response)
	GET        [][]interface{}
	POST       [][]interface{}
	FileCache  hmap.HashMap
	Config     Config
}

Server type

func Express

func Express(cfg Config) Server

Express (cfg *Config) (Server) returns a Server object

func (*Server) Get

func (s *Server) Get(path string, handler func(req *Request, res *Response))

Get (path string, handler func(req *Request, res *Response)) appends given handler to GET routes

func (*Server) Listen

func (s *Server) Listen() error

Listen () (error) listens for connections

func (*Server) ListenTLS

func (s *Server) ListenTLS(certificate string, key string) error

ListenTLS (certificate string, key string) listens for connections, and process it with tls

func (*Server) Post

func (s *Server) Post(path string, handler func(req *Request, res *Response))

Post (path string, handler func(req *Request, res *Response)) appends given handler to POST routes

func (*Server) Static

func (s *Server) Static(path string, realPath string)

Static (path string, realPath string) serves static files

func (*Server) Use

func (s *Server) Use(middleware func(req *Request, res *Response))

Use (middleware func(req *Request, res *Response)) appends given middleware to server

Jump to

Keyboard shortcuts

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