skeleton

package module
v0.0.0-...-5570f1b Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: MIT Imports: 14 Imported by: 0

README

Go Report Card

Go-Skeleton

Skeleton web framework for go.

Example site can be found in example folder or downloaded from the example branch

Components

Router

Go-Router

Regex pattern matching router.

Middleware Dispatcher

Go-Dispatcher

Middleware dispatcher using Go-Router

Go-Overlay

Go-Overlay

Go template engine

Other Components

Go-Strorage

DB/Reddis component.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//Template overlay.Overlay
	Template overlay.Overlay
	//WaitFlag graceful shutdown delay
	WaitFlag time.Duration
	//WriteTimeoutFlag HTTP time.duration
	WriteTimeoutFlag time.Duration
	//ReadTimeoutFlag HTTP time.duration
	ReadTimeoutFlag time.Duration
	//IdleTimeoutFlag HTTP time.duration
	IdleTimeoutFlag time.Duration
	//DevMode disable browser cache and enabled debugging pprof
	DevMode bool
)

Functions

func DecodeJSON

func DecodeJSON(r *http.Request, v interface{}) error

DecodeJSON decodes json response to interface

func GetInputs

func GetInputs(r *http.Request, input ...string) (map[string]string, error)

GetInputs returns all r.FormValues from http request missing inputs are returned as empty strings

func InitFlags

func InitFlags()

InitFlags create skeleton flags

func LoadTemplate

func LoadTemplate(t overlay.Overlay)

LoadTemplate overlay.Overlay

func LoggingMiddleware

func LoggingMiddleware() dispatcher.Middleware

LoggingMiddleware log response load time

func NewHTTPServer

func NewHTTPServer(httpAddr string, mux *http.ServeMux) *http.Server

NewHTTPServer returns instance of http.Server.

func Render

func Render(w http.ResponseWriter, layout string, data interface{}) error

Render page from template

func RenderStatic

func RenderStatic(w http.ResponseWriter, r *http.Request, layout string, tag string) error

RenderStatic Render Cached static page render

func RenderTagged

func RenderTagged(w http.ResponseWriter, r *http.Request, layout string, tag string, data interface{}) error

RenderTagged page from template

func ServeSite

func ServeSite(s Site)

ServeSite runs server

func VerifyEmail

func VerifyEmail(email string) bool

VerifyEmail pattern match

Types

type Recaptcha

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

Recaptcha configuration

func NewRecaptcha

func NewRecaptcha(token, url, secret string) *Recaptcha

NewRecaptcha returns instance of Recaptcha

func (*Recaptcha) Verify

func (r *Recaptcha) Verify(input string) bool

Verify Recaptcha challenge

type RecaptchaResponse

type RecaptchaResponse struct {
	Success bool `json:"success"`
}

RecaptchaResponse challenge response from Recaptcha servers

type Response

type Response struct {
	Code  int
	Data  string
	Error string
}

Response JSON data struct

func NewResponse

func NewResponse() *Response

NewResponse returns simple Response example

func (*Response) Respond

func (r *Response) Respond(w http.ResponseWriter)

Respond writes data to http.ResponseWriter

type ResponseInterface

type ResponseInterface interface {
	Respond(w http.ResponseWriter)
}

ResponseInterface for responding to requests

type Site

type Site interface {
	//Load template files
	Load() overlay.Overlay
	//Get Dispatch routes
	Dispatcher() dispatcher.Dispatcher
	//NewHTTPServer
	NewHTTPServer() *http.Server
}

Site interface website extraction from skeleton

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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