mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-12 08:23:58 +02:00
7b385bf163
* logs alloc Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * fix allocs Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * fix allocs Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * tunnel allocs Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * try to fix tunnel Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * cache cipher for send Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * more logger Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * more logger Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * more logger Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * more logger Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * more logger Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * more logger Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org> * more logger Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
// Package web provides web based micro services
|
|
package web
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/micro/go-micro/v2/logger"
|
|
)
|
|
|
|
// 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
|
|
}
|
|
|
|
type Option func(o *Options)
|
|
|
|
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 }
|
|
|
|
log = logger.NewHelper(logger.DefaultLogger).WithFields(map[string]interface{}{"service": "web"})
|
|
)
|
|
|
|
// NewService returns a new web.Service
|
|
func NewService(opts ...Option) Service {
|
|
return newService(opts...)
|
|
}
|