httpserver

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2018 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpServer

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

任意のタイミングで終了可能なサーバ。

Usage

srv := NewHttpServer("0.0.0.0:8080", ServerArgs{})
srv.Start()
go func() {
	time.Sleep(time.Second)
	srv.Stop()
}
err := srv.Wait()

func NewHttpServer

func NewHttpServer(addr string, router http.Handler) *HttpServer

func (*HttpServer) Addr

func (srv *HttpServer) Addr() string

Addr returns binded address of this server.

func (*HttpServer) Start

func (srv *HttpServer) Start() error

HTTPサーバといくつかのハンドラを起動する。 この関数の実行終了後、Addr()から実際にlistenされたアドレスとポート番号を取得出来る。

func (*HttpServer) Stop

func (srv *HttpServer) Stop()

HTTPサーバと全てのハンドラを停止する。

func (*HttpServer) Url

func (srv *HttpServer) Url() string

Url returns complete URL with prefix "http://".

func (*HttpServer) Wait

func (srv *HttpServer) Wait() error

HTTPサーバが終了するまで待機する。

Jump to

Keyboard shortcuts

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