myhttp

package
v0.0.0-...-f341fdd Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default404Handler

func Default404Handler(request Request, response *Response)

func SendResponse

func SendResponse(conn net.Conn, response *Response) error

Types

type Request

type Request struct {
	Conn        net.Conn
	Method      string
	Path        string
	HTTPVersion string
	Body        string
	Headers     map[string]string
}

func ReadRequest

func ReadRequest(conn net.Conn) (req *Request, err error)

type Response

type Response struct {
	HTTPVersion  string
	StatusCode   uint16
	ReasonPhrase string
	Headers      map[string]string
	Body         string
}

func (*Response) EnsureReady

func (r *Response) EnsureReady() error

Checks if all required fields are set to send out the response: `HTTPVersion`, `StatusCode`, and `ReasonPhrase`.

func (*Response) Prep

func (r *Response) Prep()

func (*Response) String

func (r *Response) String() string

Returns a valid and whole HTTP response.

type Server

type Server struct {
	Name    string
	Network string
	Address string
	// contains filtered or unexported fields
}

func NewTCPServer

func NewTCPServer(address string) *Server

func (*Server) InitResponse

func (s *Server) InitResponse() *Response

A default response

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) SetHandler

func (s *Server) SetHandler(pattern string, handler func(Request, *Response)) error

func (*Server) UnsetHandler

func (s *Server) UnsetHandler(pattern string)

You shouldn't need this

Jump to

Keyboard shortcuts

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