web

package
v0.0.0-...-09e84be Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//KeyAppContext is key to get AppContext in middleware
	KeyAppContext key = iota
	//KeyAPIVersion is key to get set API version in context
	KeyAPIVersion key = iota
)

Variables

This section is empty.

Functions

func APIVersionCtx

func APIVersionCtx(version string) func(next http.Handler) http.Handler

APIVersionCtx adds api version to request Context

func AuthRequired

func AuthRequired() func(next http.Handler) http.Handler

AuthRequired check whether request contais valid JWT token

Types

type APIVersion

type APIVersion struct {
	Router chi.Router
	V      string
}

APIVersion struct to hold api version information

func NewAPIVersion

func NewAPIVersion(version string, r *chi.Mux) *APIVersion

NewAPIVersion create new version path for APIs like /v1 or /v2 etc.

type Result

type Result struct {
	HTTPStatus int
	ErrCode    int
	ErrText    string
	Data       string //interface{}

}

Result is datatype that will be retured from all APIs

func NewResult

func NewResult() *Result

NewResult object

func NewResultFilled

func NewResultFilled(data string, httpstatus int, errcode int, errmsg string) *Result

NewResultFilled creates a new instance of Result struct with given parameters

type Server

type Server struct {
	*http.Server
	Router *chi.Mux
}

Server is web server

func NewServer

func NewServer() *Server

NewServer Create new Server object

func (*Server) Start

func (s *Server) Start()

Start starts listening the server of set ports

Jump to

Keyboard shortcuts

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