web

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAddress is used if no other is specified.
	DefaultAddress = ":8080"
)

Variables

This section is empty.

Functions

func CreateHttpBuilder

func CreateHttpBuilder(routerConfig func(router router.IRouterBuilder)) *abstractions.HostBuilder

region Create the builder of Web host

func NewFastHTTPHandler

func NewFastHTTPHandler(h http.Handler) fasthttp.RequestHandler

func Upgrade

func Upgrade(ctx *context.HttpContext, upgraderFunc func(*websocket.Conn))

serveWs handles socket requests from the peer.

func UpgradeHandler

func UpgradeHandler(upgraderFunc func(*websocket.Conn)) func(ctx *context.HttpContext)

Types

type ApplicationBuilder

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

application builder struct

func New

create application builder when combo all handlers to middleware

func NewWebApplicationBuilder

func NewWebApplicationBuilder() *ApplicationBuilder

create new web application builder

func UseClassic

func UseClassic() *ApplicationBuilder

create classic application builder

func (*ApplicationBuilder) Build

func (this *ApplicationBuilder) Build() interface{}

build and combo all middleware to request delegate (ServeHTTP(w http.ResponseWriter, r *http.Request)) return abstractions.IRequestDelegate type

func (*ApplicationBuilder) ServeHTTP

func (app *ApplicationBuilder) ServeHTTP(w http.ResponseWriter, r *http.Request)

middlewares of Server MiddlewareHandler , request port.

func (*ApplicationBuilder) SetHostBuildContext

func (this *ApplicationBuilder) SetHostBuildContext(context *abstractions.HostBuilderContext)

func (*ApplicationBuilder) SetJsonSerializer

func (self *ApplicationBuilder) SetJsonSerializer(encoder extension.Encoder) *ApplicationBuilder

SetJsonSerializer set json serializer for response

func (*ApplicationBuilder) Use

func (app *ApplicationBuilder) Use(provider interface{})

func (*ApplicationBuilder) UseEndpoints

func (self *ApplicationBuilder) UseEndpoints(configure func(router.IRouterBuilder)) *ApplicationBuilder

func (*ApplicationBuilder) UseFunc

func (app *ApplicationBuilder) UseFunc(handlerFunc middlewares.MiddlewareHandlerFunc)

apply handler func middleware in builder

func (*ApplicationBuilder) UseHandler

func (app *ApplicationBuilder) UseHandler(handler http.Handler)

apply handler middleware in builder

func (*ApplicationBuilder) UseHandlerFunc

func (app *ApplicationBuilder) UseHandlerFunc(handlerFunc func(rw http.ResponseWriter, r *http.Request))

apply handler func middleware in builder

func (*ApplicationBuilder) UseMiddleware

func (app *ApplicationBuilder) UseMiddleware(handler middlewares.MiddlewareHandler)

apply middleware in builder

func (*ApplicationBuilder) UseMiddlewareFront

func (app *ApplicationBuilder) UseMiddlewareFront(handler middlewares.MiddlewareHandler)

apply middleware in builder

func (*ApplicationBuilder) UseMvc

func (self *ApplicationBuilder) UseMvc(configure func(builder *mvc.ControllerBuilder)) *ApplicationBuilder

UseMvc after create builder , apply router and logger and recovery middleware

func (*ApplicationBuilder) UseStatic

func (app *ApplicationBuilder) UseStatic(patten string, path string)

apply static middleware in builder

func (*ApplicationBuilder) UseStaticAssets

func (app *ApplicationBuilder) UseStaticAssets()

type FastHttpServer

type FastHttpServer struct {
	IsTLS                   bool
	Addr, CertFile, KeyFile string
	// contains filtered or unexported fields
}

func NewFastHttp

func NewFastHttp(addr string) *FastHttpServer

func NewFastHttpByConfig

func NewFastHttpByConfig(config hostenv.HttpServerConfig) *FastHttpServer

func NewFastHttps

func NewFastHttps(addr string, cert string, key string) *FastHttpServer

func (*FastHttpServer) GetAddr

func (server *FastHttpServer) GetAddr() string

func (*FastHttpServer) Run

func (server *FastHttpServer) Run(context *abstractions.HostBuilderContext) (e error)

func (*FastHttpServer) Shutdown

func (server *FastHttpServer) Shutdown()

type HandlerFunc

type HandlerFunc = func(ctx *context.HttpContext)

func WarpHandlerFunc

func WarpHandlerFunc(h func(w http.ResponseWriter, r *http.Request)) HandlerFunc

func WarpHttpHandlerFunc

func WarpHttpHandlerFunc(h http.Handler) HandlerFunc

type HttpServer

type HttpServer struct {
	IsTLS                   bool
	Addr, CertFile, KeyFile string
	// contains filtered or unexported fields
}

func DefaultHttpServer

func DefaultHttpServer(addr string) *HttpServer

func DefaultHttps

func DefaultHttps(addr string, cert string, key string) *HttpServer

func NewDefaultHttpByConfig

func NewDefaultHttpByConfig(config hostenv.HttpServerConfig) *HttpServer

func (*HttpServer) GetAddr

func (server *HttpServer) GetAddr() string

func (*HttpServer) Run

func (server *HttpServer) Run(context *abstractions.HostBuilderContext) (e error)

func (*HttpServer) Shutdown

func (server *HttpServer) Shutdown()

type IRequestDelegate

type IRequestDelegate interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

type NetHTTPResponseWriter

type NetHTTPResponseWriter struct {
	Ctx *fasthttp.RequestCtx

	IsHijackerConn bool
	// contains filtered or unexported fields
}

func (*NetHTTPResponseWriter) Header

func (w *NetHTTPResponseWriter) Header() http.Header

func (*NetHTTPResponseWriter) StatusCode

func (w *NetHTTPResponseWriter) StatusCode() int

func (*NetHTTPResponseWriter) Write

func (w *NetHTTPResponseWriter) Write(p []byte) (int, error)

func (*NetHTTPResponseWriter) WriteHeader

func (w *NetHTTPResponseWriter) WriteHeader(statusCode int)

type WebHost

type WebHost struct {
	HostContext *abstractions.HostBuilderContext
	// contains filtered or unexported fields
}

func NewWebHost

func NewWebHost(server abstractions.IServer, hostContext *abstractions.HostBuilderContext) WebHost

func (WebHost) Run

func (host WebHost) Run()

func (WebHost) SetAppMode

func (host WebHost) SetAppMode(mode string)

func (WebHost) Shutdown

func (host WebHost) Shutdown()

Shutdown is Graceful stop application

func (WebHost) StopApplicationNotify

func (host WebHost) StopApplicationNotify()

type WebHostBuilder

type WebHostBuilder struct {
	abstractions.HostBuilder
}

func CreateBlankWebBuilder

func CreateBlankWebBuilder() *WebHostBuilder

func CreateMvcBuilder

func CreateMvcBuilder(appFunc func(*ApplicationBuilder)) *WebHostBuilder

func NewWebHostBuilder

func NewWebHostBuilder() *WebHostBuilder

func (*WebHostBuilder) Configure

func (host *WebHostBuilder) Configure(configure func(*ApplicationBuilder)) *WebHostBuilder

func (*WebHostBuilder) UseConfiguration

func (host *WebHostBuilder) UseConfiguration(configuration abstractions.IConfiguration) *WebHostBuilder

type WebHostBuilderDecorator

type WebHostBuilderDecorator struct {
}

func NewWebHostBuilderDecorator

func NewWebHostBuilderDecorator() WebHostBuilderDecorator

NewWebHostBuilderDecorator WebHostBuilderDecorator.

func (WebHostBuilderDecorator) OverrideConfigure

func (decorator WebHostBuilderDecorator) OverrideConfigure(configureFunc interface{}, builder abstractions.IApplicationBuilder)

OverrideConfigure is configure function by web application builder.

func (WebHostBuilderDecorator) OverrideIOCInnerConfigures

func (decorator WebHostBuilderDecorator) OverrideIOCInnerConfigures(serviceCollection *dependencyinjection.ServiceCollection)

OverrideInnerConfigures inner configures for IOC

func (WebHostBuilderDecorator) OverrideNewApplicationBuilder

func (decorator WebHostBuilderDecorator) OverrideNewApplicationBuilder(context *abstractions.HostBuilderContext) abstractions.IApplicationBuilder

OverrideNewApplicationBuilder create web application builder.

func (WebHostBuilderDecorator) OverrideNewHost

OverrideNewHost Create WebHost.

Jump to

Keyboard shortcuts

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