http

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CtxType    Type
	ServerType Type
	ResType    Type
	ClientType Type
	HttpModule Module
	ServerPool map[int64]*Server
	ClientPool map[int64]*Client
)

Functions

This section is empty.

Types

type Client

type Client struct {
	ID int64
	http.Client
}

func NewClient

func NewClient(timeout time.Duration) *Client

func (*Client) Do

func (c *Client) Do(method, url, data string, header map[string]string) (res *http.Response, err error)

func (*Client) Form

func (c *Client) Form(url string, frm map[string][]string) (*http.Response, error)

func (*Client) Get

func (c *Client) Get(url string) (*http.Response, error)

func (*Client) Head

func (c *Client) Head(url string) (*http.Response, error)

func (*Client) Post

func (c *Client) Post(url, contentType, data string) (*http.Response, error)

type Ctx

type Ctx struct {
	*http.Request
	http.ResponseWriter
}

func (*Ctx) Body

func (c *Ctx) Body() (*gabs.Container, error)

func (*Ctx) Header

func (c *Ctx) Header(name string) string

func (*Ctx) Method

func (c *Ctx) Method() string

func (*Ctx) Query

func (c *Ctx) Query(name string) string

func (*Ctx) SendFile

func (c *Ctx) SendFile(path string) error

func (*Ctx) SendJson

func (c *Ctx) SendJson(data *gabs.Container)

func (*Ctx) SendString

func (c *Ctx) SendString(data string)

func (*Ctx) SetHeader

func (c *Ctx) SetHeader(name, value string)

func (*Ctx) SetStatus

func (c *Ctx) SetStatus(code int)

func (*Ctx) Vars

func (c *Ctx) Vars(name string) string

type Server

type Server struct {
	ID int64

	Addr string
	*http.Server
	*mux.Router
	// contains filtered or unexported fields
}

func NewServer

func NewServer(addr string, log func(string)) *Server

func (*Server) Connect

func (s *Server) Connect(path string, fn func(ctx *Ctx))

func (*Server) Delete

func (s *Server) Delete(path string, fn func(ctx *Ctx))

func (*Server) File

func (s *Server) File(path, prefix, dir string)

func (*Server) Get

func (s *Server) Get(path string, fn func(ctx *Ctx))

func (*Server) Head

func (s *Server) Head(path string, fn func(ctx *Ctx))

func (*Server) Options

func (s *Server) Options(path string, fn func(ctx *Ctx))

func (*Server) Patch

func (s *Server) Patch(path string, fn func(ctx *Ctx))

func (*Server) Post

func (s *Server) Post(path string, fn func(ctx *Ctx))

func (*Server) Put

func (s *Server) Put(path string, fn func(ctx *Ctx))

func (*Server) Route

func (s *Server) Route(path string, fn func(ctx *Ctx))

func (*Server) Running

func (s *Server) Running() bool

func (*Server) Start

func (s *Server) Start(
	cors bool,
	allowHeader []string,
	allowedMethods []string,
	allowedOrigins []string,
	exposedHeaders []string,
	maxAge int,
	allowCredentials int,
)

func (*Server) Stop

func (s *Server) Stop(n time.Duration) (error, context.CancelFunc)

func (*Server) Trace

func (s *Server) Trace(path string, fn func(ctx *Ctx))

Jump to

Keyboard shortcuts

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