kacaw

package module
v0.0.0-...-9d36acb Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 9 Imported by: 0

README

kacaw

Kacaw is a HTTP Framework for Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	ResponseWriter http.ResponseWriter
	Request        *http.Request
	// contains filtered or unexported fields
}
type Cookie struct {
	Name     string
	Value    string
	Path     string
	Domain   string
	Expires  time.Time
	Secure   bool
	HttpOnly bool
}

type CookieManager

type CookieManager interface {
	SetCookie(w http.ResponseWriter, cookie *Cookie)
	GetCookie(r *http.Request, name string) (*http.Cookie, error)
}

type DefaultCookieManager

type DefaultCookieManager struct{}

func (*DefaultCookieManager) GetCookie

func (cm *DefaultCookieManager) GetCookie(r *http.Request, name string) (*http.Cookie, error)

func (*DefaultCookieManager) SetCookie

func (cm *DefaultCookieManager) SetCookie(w http.ResponseWriter, cookie *Cookie)

type Router

type Router struct {
	Routes map[string]map[string]http.HandlerFunc

	CookieManager CookieManager
	// contains filtered or unexported fields
}

func Default

func Default(options ...RouterOptions) *Router

func (*Router) CONNECT

func (r *Router) CONNECT(path string, handler http.HandlerFunc)

func (*Router) DELETE

func (r *Router) DELETE(path string, handler http.HandlerFunc)

func (*Router) GET

func (r *Router) GET(path string, handler http.HandlerFunc)

func (*Router) GetCookie

func (r *Router) GetCookie(req *http.Request, name string) (*http.Cookie, error)

func (*Router) GetSession

func (r *Router) GetSession(session *Session, key string) string

func (*Router) HEAD

func (r *Router) HEAD(path string, handler http.HandlerFunc)

func (*Router) HTML

func (r *Router) HTML(status int, filename string, data interface{}, w http.ResponseWriter)

func (*Router) JSON

func (r *Router) JSON(status int, data interface{}, w http.ResponseWriter)

func (*Router) LoadHTMLFiles

func (r *Router) LoadHTMLFiles(filenames ...string)

func (*Router) OPTIONS

func (r *Router) OPTIONS(path string, handler http.HandlerFunc)

func (*Router) PATCH

func (r *Router) PATCH(path string, handler http.HandlerFunc)

func (*Router) POST

func (r *Router) POST(path string, handler http.HandlerFunc)

func (*Router) PUT

func (r *Router) PUT(path string, handler http.HandlerFunc)

func (*Router) Redirect

func (r *Router) Redirect(w http.ResponseWriter, req *http.Request, url string)

func (*Router) Run

func (r *Router) Run(port string)

func (*Router) SaveFile

func (r *Router) SaveFile(file multipart.File, header *multipart.FileHeader, path string) error

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Router) SetCookie

func (r *Router) SetCookie(w http.ResponseWriter, cookie *Cookie)

func (*Router) SetSession

func (r *Router) SetSession(session *Session, key, value string)

func (*Router) Static

func (r *Router) Static(filenames ...string)

func (*Router) TRACE

func (r *Router) TRACE(path string, handler http.HandlerFunc)

type RouterOptions

type RouterOptions struct {
	CookieManager CookieManager
}

type Session

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

func NewSession

func NewSession(cookie *Cookie) *Session

func (*Session) Get

func (s *Session) Get(key string) string

func (*Session) Set

func (s *Session) Set(key, value string)

Jump to

Keyboard shortcuts

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