server

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Config config.Config

	Request  *Request
	Response *Response
	// contains filtered or unexported fields
}

func NewContext

func NewContext(cfg config.Config, route config.Route, w http.ResponseWriter, r *http.Request) *Context

func (*Context) GetStr

func (c *Context) GetStr(key string) (string, error)

type JsonResponse

type JsonResponse struct {
	StatusCode int
	Data       map[string]interface{}
	Error      string
}

type Request

type Request struct {
	*http.Request
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(ctx *Context, r *http.Request) *Request

func (*Request) GetParam

func (r *Request) GetParam(k string) string

type Response

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

func NewResponse

func NewResponse(ctx *Context, w http.ResponseWriter) *Response

func (*Response) SetStatusCode

func (r *Response) SetStatusCode(code int) error

type Server

type Server struct {
	HTTPServer *http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg config.Config, isProduction bool) (*Server, error)

func (*Server) AddPrehandler

func (s *Server) AddPrehandler(fn func(w http.ResponseWriter, r *http.Request) bool)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) NotFound

func (s *Server) NotFound(w http.ResponseWriter, r *http.Request)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Stop

func (s *Server) Stop() error

Jump to

Keyboard shortcuts

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