Documentation
¶
Overview ¶
Package httpserver provides http server as module.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opt ¶
func WithShutdownTimeout ¶
WithShutdownTimeout sets timeout for graceful shutdown.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func New ¶
New creates Server module with given options.
Example ¶
package main
import (
"fmt"
"net/http"
"time"
"github.com/elisasre/go-common/v2/service/module/httpserver"
)
func main() {
httpserver.New(
httpserver.WithServer(&http.Server{ReadHeaderTimeout: time.Second}),
httpserver.WithAddr("127.0.0.1:0"),
httpserver.WithHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello")
})),
)
}
func (*Server) Init ¶
Init starts net.Listener after applying all options. Options are applied in same order as they were provided.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package pprof provides pprof handler options for httpserver module.
|
Package pprof provides pprof handler options for httpserver module. |
|
Package prom provides prometheus metrics handler options for httpserver module.
|
Package prom provides prometheus metrics handler options for httpserver module. |
Click to show internal directories.
Click to hide internal directories.