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: 0

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