server

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 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) GetLang added in v1.0.7

func (c *Context) GetLang() string

func (*Context) GetLangShort added in v1.0.7

func (c *Context) GetLangShort() string

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) Redirect added in v1.1.9

func (r *Response) Redirect(url string) error

func (*Response) SetHeader added in v1.1.9

func (r *Response) SetHeader(key, value string) error

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, isRunningMode 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) Reload added in v1.2.0

func (s *Server) Reload() error

func (*Server) ServeHTTP

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

func (*Server) Stop

func (s *Server) Stop() error

type StringResponse added in v1.1.2

type StringResponse struct {
	StatusCode int
	Data       string
	Error      string
}

Jump to

Keyboard shortcuts

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