1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00
go-micro/web/web.go
Vasiliy Tolstov e0c9234c0e
web: use default logger (#1577)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-27 00:03:05 +03:00

46 lines
972 B
Go

// Package web provides web based micro services
package web
import (
"context"
"net/http"
"time"
"github.com/google/uuid"
)
// Service is a web service with service discovery built in
type Service interface {
Client() *http.Client
Init(opts ...Option) error
Options() Options
Handle(pattern string, handler http.Handler)
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
Run() error
}
//Option for web
type Option func(o *Options)
//Web basic Defaults
var (
// For serving
DefaultName = "go-web"
DefaultVersion = "latest"
DefaultId = uuid.New().String()
DefaultAddress = ":0"
// for registration
DefaultRegisterTTL = time.Minute
DefaultRegisterInterval = time.Second * 30
// static directory
DefaultStaticDir = "html"
DefaultRegisterCheck = func(context.Context) error { return nil }
)
// NewService returns a new web.Service
func NewService(opts ...Option) Service {
return newService(opts...)
}