Restructure project similar to hello and graph

This commit is contained in:
Thomas Boerger
2019-12-06 15:03:43 +01:00
parent 5c15745a3a
commit acd6d6e7f5
46 changed files with 1906 additions and 751 deletions
+59
View File
@@ -0,0 +1,59 @@
package http
import (
"github.com/owncloud/ocis-ocs/pkg/config"
"github.com/owncloud/ocis-ocs/pkg/flagset"
"github.com/owncloud/ocis-ocs/pkg/service/v0"
"github.com/owncloud/ocis-ocs/pkg/version"
"github.com/owncloud/ocis-pkg/middleware"
"github.com/owncloud/ocis-pkg/service/http"
)
// Server initializes the http service and server.
func Server(opts ...Option) (http.Service, error) {
options := newOptions(opts...)
service := http.NewService(
http.Logger(options.Logger),
http.Namespace("go.micro.web"),
http.Name("ocs"),
http.Version(version.String),
http.Address(options.Config.HTTP.Addr),
http.Context(options.Context),
http.Flags(flagset.RootWithConfig(config.New())...),
http.Flags(flagset.ServerWithConfig(config.New())...),
)
handle := svc.NewService(
svc.Logger(options.Logger),
svc.Config(options.Config),
svc.Middleware(
middleware.RealIP,
middleware.RequestID,
middleware.Cache,
middleware.Cors,
middleware.Secure,
middleware.Version(
"ocs",
version.String,
),
middleware.Logger(
options.Logger,
),
),
)
{
handle = svc.NewInstrument(handle, options.Metrics)
handle = svc.NewLogging(handle, options.Logger)
handle = svc.NewTracing(handle)
}
service.Handle(
"/",
handle,
)
service.Init()
return service, nil
}