webapp

package
v0.0.0-...-696e5ce Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	HTMLDir   string
	StaticDir string
	Conn      *grpc.ClientConn
}

App struct

func (*App) ClientError

func (app *App) ClientError(w http.ResponseWriter, status int)

ClientError helper sends a specific status code and corresponding description to the user.

func (*App) DefaultHandler

func (app *App) DefaultHandler(w http.ResponseWriter, r *http.Request)

DefaultHandler handles any requests not matched by a previous path

func (*App) Forbidden

func (app *App) Forbidden(w http.ResponseWriter)

Forbidden writes a 403 forbidden to the passed responsewriter

func (*App) GetCode

func (app *App) GetCode(w http.ResponseWriter, r *http.Request)

GetCode ...

func (*App) GetStats

func (app *App) GetStats(w http.ResponseWriter, r *http.Request)

GetStats ...

func (*App) GetURL

func (app *App) GetURL(w http.ResponseWriter, r *http.Request)

GetURL ...

func (*App) Index

func (app *App) Index(w http.ResponseWriter, r *http.Request)

Index ...

func (*App) NotFound

func (app *App) NotFound(w http.ResponseWriter)

NotFound helper. This is simply a convenience wrapper around ClientError which sends a 404 Not Found response to the user.

func (*App) RenderHTML

func (app *App) RenderHTML(w http.ResponseWriter, r *http.Request, page string, data *HTMLData)

RenderHTML handles data

func (*App) Routes

func (app *App) Routes() *mux.Router

Routes ...

func (*App) ServerError

func (app *App) ServerError(w http.ResponseWriter, err error)

ServerError helper writes an error message and stack trace to the log, then sends a generic 500 Internal Server Error response to the user.

type HTMLData

type HTMLData struct {
	Data  string
	Error string
	Stats Statistics
}

HTMLData struct for passing data to html templates

type Statistics

type Statistics struct {
	Code         string `json:"code"`
	URL          string `json:"url"`
	CreatedAt    string `json:"created_at"`
	LastAccessed string `json:"last_accessed"`
	Clicks       string `json:"clicks"`
}

Statistics defines the Code:URL structure

Jump to

Keyboard shortcuts

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