http

package
v0.0.0-...-786156a Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentType   = "Content-Type"
	HeaderContentLength = "Content-Length"
	HeaderHost          = "Host"
	HeaderUserAgent     = "User-Agent"
)
View Source
const (
	MethodGet  = "GET"
	MethodPost = "POST"
)
View Source
const HeaderConnection = "Connection"
View Source
const StatusBadRequest = "400 Bad Request"
View Source
const StatusCreated = "201 Created"
View Source
const StatusInternalServerErr = "500 Internal Server Error"
View Source
const StatusNotFound = "404 Not Found"
View Source
const StatusOK = "200 OK"

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(req *Request, res *Response)

type Request

type Request struct {
	Path        string
	Method      string
	HttpVersion string
	Headers     map[string]string
	Body        string
}

type Response

type Response struct {
	Status  string
	Headers map[string]string
	Content string
}

func NewResponse

func NewResponse(status string) *Response

func (*Response) SetContent

func (r *Response) SetContent(contentType, content string)

type Server

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

func NewServer

func NewServer() *Server

func (*Server) SetHandler

func (s *Server) SetHandler(pattern string, handler Handler)

func (*Server) Start

func (s *Server) Start(port int) error

Jump to

Keyboard shortcuts

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