server

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMethod

func IsMethod(method string) bool

IsMethod takes in a string and validates whether it is a Method or not

Types

type Context

type Context struct {
}
type Cookie struct {
	// contains filtered or unexported fields
}

Cookie represents a browser cookie

func CookiesFromHeader

func CookiesFromHeader(header string) []Cookie

CookiesFromHeader gets the cookies from a Cookie header

func NewCookie

func NewCookie(name, value string) Cookie

NewCookie creates a new Cookie

func (Cookie) Domain

func (c Cookie) Domain(domain string) Cookie

Domain sets the Domain attribute

func (Cookie) Expires

func (c Cookie) Expires(expires time.Time) Cookie

Expires sets the Expires attribute

func (Cookie) HttpOnly

func (c Cookie) HttpOnly(httpOnly bool) Cookie

HttpOnly sets the HttpOnly attribute

func (Cookie) MaxAge

func (c Cookie) MaxAge(maxAge time.Duration) Cookie

MaxAge sets the MaxAge attribute

func (Cookie) Name

func (c Cookie) Name() string

Name returns the Cookie name

func (Cookie) Path

func (c Cookie) Path(path string) Cookie

Path sets the Path attribute

func (Cookie) SameSite

func (c Cookie) SameSite(sameSite SameSite) Cookie

SameSite sets the SameSite attribute

func (Cookie) Secure

func (c Cookie) Secure(secure bool) Cookie

Secure sets the Secure attribute

func (Cookie) ToHeader

func (c Cookie) ToHeader() string

ToHeader creates a HTTP response header for setting the Cookie

func (Cookie) Value

func (c Cookie) Value() string

Value returns the Cookie value

type FormData

type FormData struct {
	Values map[string]string
	Files  map[string]struct {
		Filename string
		Data     []byte
	}
}

FormData is TODO

type Handler

type Handler func()

type Method

type Method string

Method HTTP method

const (
	M_GET     Method = "GET"
	M_HEAD    Method = "HEAD"
	M_POST    Method = "POST"
	M_PUT     Method = "PUT"
	M_DELETE  Method = "DELETE"
	M_CONNECT Method = "CONNECT"
	M_OPTIONS Method = "OPTIONS"
	M_TRACE   Method = "TRACE"
)

type Request

type Request struct {
	Method Method
	// Version string
	Host       string
	RequestURI string
	Headers    map[string]string
	FormData   FormData
	Cookies    []Cookie
	Body       []byte
}

Request represents a HTTP request in a struct

func ParseRequest

func ParseRequest(req []byte) (*Request, error)

ParseRequest converts a []byte to a *Request if it is a valid HTTP request

func (*Request) GetHeader

func (r *Request) GetHeader(name string) string

GetHeader gets a header. If it does not exist, return an empty string

type Response

type Response struct {
}

type Route

type Route struct {
}

type Router

type Router struct {
}

type SameSite

type SameSite string

SameSite represents a SameSite setting in a Cookie

const (
	SS_LAX    SameSite = "Lax"
	SS_NONE   SameSite = "None"
	SS_STRICT SameSite = "Strict"
)

type Server

type Server struct {
	Router   *http.Handler
	Listener *net.TCPListener

	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	// contains filtered or unexported fields
}

func CreateServer

func CreateServer(address string, router *http.Handler) (*Server, error)

CreateServer creates a *Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe()

ListenAndServe listens for incoming connections, and passes them onto handle.

func (*Server) Stop

func (s *Server) Stop()

Stop forces the listener to stop

Jump to

Keyboard shortcuts

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