webfr

package module
v0.0.0-...-08553b8 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

README

webfr

forthebadge

  • A powerful go web framework for highly scalable and resource efficient web application

Installation:

go get -u github.com/krishpranav/webfr

Examples:

package main

import (
    "github.com/krishpranav/webfr"
)

func main() {
    wb := webfr.New()

    wb.Get("/hello", func(ctx webfr.Context) {
        ctx.SendString("Helo Friends!!")
    })

    wb.Start(":3000")
}
  • for more tutorials visit the docs

Documentation

Index

Examples

Constants

View Source
const (
	Version = "1.0.0"
	Name    = "WebFramework"
)
View Source
const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH"
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	MethodOptions = "OPTIONS"
	MethodTrace   = "TRACE"
)
View Source
const (
	StatusContinue           = 100
	StatusSwitchingProtocols = 101
	StatusProcessing         = 102

	StatusOK                   = 200
	StatusCreated              = 201
	StatusAccepted             = 202
	StatusNonAuthoritativeInfo = 203
	StatusNoContent            = 204
	StatusResetContent         = 205
	StatusPartialContent       = 206
	StatusMultiStatus          = 207
	StatusAlreadyReported      = 208
	StatusIMUsed               = 226

	StatusMultipleChoices  = 300
	StatusMovedPermanently = 301
	StatusFound            = 302
	StatusSeeOther         = 303
	StatusNotModified      = 304
	StatusUseProxy         = 305

	StatusTemporaryRedirect = 307
	StatusPermanentRedirect = 308

	StatusBadRequest                   = 400
	StatusUnauthorized                 = 401
	StatusPaymentRequired              = 402
	StatusForbidden                    = 403
	StatusNotFound                     = 404
	StatusMethodNotAllowed             = 405
	StatusNotAcceptable                = 406
	StatusProxyAuthRequired            = 407
	StatusRequestTimeout               = 408
	StatusConflict                     = 409
	StatusGone                         = 410
	StatusLengthRequired               = 411
	StatusPreconditionFailed           = 412
	StatusRequestEntityTooLarge        = 413
	StatusRequestURITooLong            = 414
	StatusUnsupportedMediaType         = 415
	StatusRequestedRangeNotSatisfiable = 416
	StatusExpectationFailed            = 417
	StatusTeapot                       = 418
	StatusUnprocessableEntity          = 422
	StatusLocked                       = 423
	StatusFailedDependency             = 424
	StatusUpgradeRequired              = 426
	StatusPreconditionRequired         = 428
	StatusTooManyRequests              = 429
	StatusRequestHeaderFieldsTooLarge  = 431
	StatusUnavailableForLegalReasons   = 451

	StatusInternalServerError           = 500
	StatusNotImplemented                = 501
	StatusBadGateway                    = 502
	StatusServiceUnavailable            = 503
	StatusGatewayTimeout                = 504
	StatusHTTPVersionNotSupported       = 505
	StatusVariantAlsoNegotiates         = 506
	StatusInsufficientStorage           = 507
	StatusLoopDetected                  = 508
	StatusNotExtended                   = 510
	StatusNetworkAuthenticationRequired = 511
)

these codes has been take from net/http

View Source
const (
	MIMEApplicationJSON = "application/json"
)

Variables

This section is empty.

Functions

func GetString

func GetString(b []byte) string
Example
b := []byte("ABC€")
str := GetString(b)
fmt.Println(str)
fmt.Println(len(b) == len(str))

b = []byte("user")
str = GetString(b)
fmt.Println(str)
fmt.Println(len(b) == len(str))

b = nil
str = GetString(b)
fmt.Println(str)
fmt.Println(len(b) == len(str))
fmt.Println(len(str))
Output:

Types

type BeforeFunc

type BeforeFunc func(ResponseWriter)

type Context

type Context interface {
	Next()
	Context() *fasthttp.RequestCtx
	Param(key string) string
	Query(key string) string
	SendBytes(value []byte) Context
	SendString(value string) Context
	SendJSON(in interface{}) error
	Status(status int) Context
	Set(key string, value string)
	Get(key string) string
	SetLocal(key string, value interface{})
	GetLocal(key string) interface{}
	Body() string
	ParseBody(out interface{}) error
}

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter
	http.Flusher
	http.Pusher

	Status() int
	Written() bool
	Size() int
	Before(BeforeFunc)
}

type Route

type Route struct {
	Method   string
	Path     string
	Handlers handlersChain
}

type Settings

type Settings struct {
	CaseInSensitive bool

	CacheSize int

	HandleMethodNotAllowed bool

	HandleOPTIONS bool

	AutoRecover bool

	ServerName string

	MaxRequestBodySize int

	MaxRouteParams int

	MaxRequestURLLength int

	Concurrency int

	Prefork bool

	DisableCaching bool

	DisableStartupMessage bool

	DisableKeepalive bool

	DisableDefaultDate bool

	DisableDefaultContentType bool

	DisableHeaderNormalizing bool

	ReadTimeout time.Duration

	WriteTimeout time.Duration

	IdleTimeout time.Duration

	TLSEnabled bool

	TLSCertPath string

	TLSKeyPath string
}

type Webfr

type Webfr interface {
	Start(address string) error
	Stop() error
	Get(path string, handlers ...handlerFunc) *Route
	Head(path string, handlers ...handlerFunc) *Route
	Post(path string, handlers ...handlerFunc) *Route
	Put(path string, handlers ...handlerFunc) *Route
	Patch(path string, handlers ...handlerFunc) *Route
	Delete(path string, handlers ...handlerFunc) *Route
	Connect(path string, handlers ...handlerFunc) *Route
	Options(path string, handlers ...handlerFunc) *Route
	Trace(path string, handlers ...handlerFunc) *Route
	Group(prefix string, routes []*Route) []*Route
	Static(prefix, root string)
	NotFound(handlers ...handlerFunc)
	Use(middlewares ...handlerFunc)
}

func New

func New(settings ...*Settings) Webfr

Jump to

Keyboard shortcuts

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