http

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client for http requests

func NewClient

func NewClient(config *ClientConfig) (c *Client)

NewClient constructor

func (*Client) ADD

func (c *Client) ADD(url string, data interface{}, handler ClientRequestHandler) (err error)

ADD http POST method

func (*Client) Cookies added in v0.2.0

func (c *Client) Cookies(url string) []*http.Cookie

Cookies for a url. Returns nil if the given url is invalid or has no cookies set.

func (*Client) DELETE

func (c *Client) DELETE(url string, handler ClientRequestHandler) (err error)

DELETE http DELETE method

func (*Client) GET

func (c *Client) GET(url string, handler ClientRequestHandler) (err error)

GET http GET method

func (*Client) HEAD

func (c *Client) HEAD(url string) (available bool)

HEAD http HEAD method use to check resources for existance

func (*Client) UPDATE

func (c *Client) UPDATE(url string, data interface{}, handler ClientRequestHandler) (err error)

UPDATE http PUT method

type ClientConfig

type ClientConfig struct {
	Timeout time.Duration
}

ClientConfig configuration of a client

type ClientRequestHandler

type ClientRequestHandler func(resp *http.Response) (err error)

ClientRequestHandler handler function for a client request

func HandleBytes

func HandleBytes(bytes *[]byte) (handler ClientRequestHandler)

HandleBytes client bytes request handler

func HandleJSON

func HandleJSON(data interface{}) (handler ClientRequestHandler)

HandleJSON client json request handler

func HandleStatus

func HandleStatus(expected ...int) (handler ClientRequestHandler)

HandleStatus client request status handler

func HandleString

func HandleString(str *string) (handler ClientRequestHandler)

HandleString client string request handler

type RequestContext

type RequestContext struct {
	route.BaseRequestContext
	*gin.Context
	Writer  http.ResponseWriter
	Request *http.Request
}

RequestContext for a http request

type Server

type Server struct {
	route.Grouper
	// contains filtered or unexported fields
}

Server for http requests

func NewServer

func NewServer(config *ServerConfig, c service.Container) (s *Server, err error)

NewServer instance creation

func (*Server) AddCSRFProtectionGroup added in v0.2.0

func (s *Server) AddCSRFProtectionGroup(path string, middleware ...route.Middleware) (newGroup *route.Group, err error)

AddCSRFProtectionGroup adds a new group of routes that uses csrf protection to the root level of the server.

func (*Server) Start

func (s *Server) Start(onShutdown func(), startInBackground bool) (srv *http.Server, port int, err error)

Start the server, the returned error is already handled by the servers logger.

func (*Server) Use added in v0.3.0

func (s *Server) Use(middleware ...gin.HandlerFunc)

Use gin middleware on root

type ServerConfig

type ServerConfig struct {
	Port                int
	DevMode             bool
	DefaultLang         language.Tag
	Languages           []language.Tag
	ReadTimeout         time.Duration
	WriteTimeout        time.Duration
	MaxHeaderBytes      int
	CookieMaxAge        int
	CookieAuthKey       string
	CookieEncryptionKey string
	SessionName         string
	SessionKey          string
	CSRFSecret          string
	UseCSRFProtection   bool
	NotFoundHandler     gin.HandlerFunc
}

ServerConfig configuration of the http server

func DefaultServerConfig

func DefaultServerConfig(cookieAuthKey string, cookieEncryptionKey string) (c *ServerConfig)

DefaultServerConfig constructor

type Session added in v0.8.0

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

Session basic implementation

func (*Session) Get added in v0.8.0

func (s *Session) Get(key interface{}) interface{}

Get a value from the session

func (*Session) Set added in v0.8.0

func (s *Session) Set(key interface{}, val interface{}) error

Set a value to the session

Jump to

Keyboard shortcuts

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