http

package
v0.0.0-...-316355b Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	ServeHTTP(req *HttpRequest, c net.Conn)
}

type HandlerFunc

type HandlerFunc func(req *HttpRequest) HttpResponse

type HttpRequest

type HttpRequest struct {
	Method      string
	Path        string
	Ip          string
	HTTPVersion string
	Headers     map[string]string
	Body        string
	UrlParams   QueryParameter
}

func ParseHttpRequest

func ParseHttpRequest(req, ip string) *HttpRequest

type HttpResponse

type HttpResponse struct {
	Code     int
	Message  string
	Protocol string
	Body     string
	Headers  map[string]string
}

func Cr

func Cr(code int, body map[string]string) HttpResponse

create response TODO: add error

func Response

func Response(code int, body, contentType string) HttpResponse

type Mux

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

func NewMux

func NewMux() *Mux

func (*Mux) HandlerFunc

func (m *Mux) HandlerFunc(path string, handler HandlerFunc)

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(req *HttpRequest, c net.Conn)

type QueryParameter

type QueryParameter map[int]map[string]string

func (QueryParameter) Get

func (q QueryParameter) Get(name string) (string, error)

type Server

type Server struct {
	Port    int
	Addr    string
	Handler Handler
}

TODO: add timeout

func NewServer

func NewServer() *Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

Jump to

Keyboard shortcuts

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