htp

package
v0.0.0-...-fa7c36c Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: MIT Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorHandleFunc func(http.ResponseWriter, *http.Request, string)
)

globals

Functions

func Base

func Base() string

Base returns the root that all methods are mounted on

func Init

func Init()

Init sets up globals to their default state

func PreInit

func PreInit()

PreInit sets up flags

func Register

func Register(path, method string, h func(w http.ResponseWriter, r *http.Request))

Register adds a handler to this router.

func RegisterFileSystem

func RegisterFileSystem(fs http.FileSystem)

RegisterFileSystem is a custom version of Register where it adds a http.FileSystem to the router

func StartServer

func StartServer(port int)

StartServer initializes this server and listens on port

func StopServer

func StopServer()

StopServer performs a graceful shutdown of the HTTP server

Types

type Controller

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

Controller is the htp package's extension

func GetController

func GetController(r *http.Request) *Controller

GetController allows you to gain access to this method's htp.Controller

func (*Controller) Assert

func (v *Controller) Assert(condition bool, message string)

Assert will exit this http method if condition is not met

func (*Controller) AssertNilErr

func (v *Controller) AssertNilErr(err error)

func (*Controller) GetFormInt

func (v *Controller) GetFormInt(name string) (string, int64)

func (*Controller) GetFormString

func (v *Controller) GetFormString(name string) string

func (*Controller) GetQueryString

func (v *Controller) GetQueryString(name string) string

func (*Controller) RedirectIf

func (v *Controller) RedirectIf(condition bool, location string)

RedirectIf will redirct to location if condition is met

Jump to

Keyboard shortcuts

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