Files
opencloud/onlyoffice/pkg/service/v0/service.go
T
Benedikt Kulmann 61cd37113a Refactor http server
2020-11-30 16:48:48 +01:00

42 lines
830 B
Go

package svc
import (
"net/http"
"github.com/go-chi/chi"
"github.com/owncloud/ocis/onlyoffice/pkg/config"
)
// Service defines the extension handlers.
type Service interface {
ServeHTTP(http.ResponseWriter, *http.Request)
}
// NewService returns a service implementation for Service.
func NewService(opts ...Option) Service {
options := newOptions(opts...)
m := chi.NewMux()
m.Use(options.Middleware...)
svc := Onlyoffice{
config: options.Config,
mux: m,
}
m.Route(options.Config.HTTP.Root, func(r chi.Router) {})
return svc
}
// Onlyoffice defines implements the business logic for Service.
type Onlyoffice struct {
config *config.Config
mux *chi.Mux
}
// ServeHTTP implements the Service interface.
func (g Onlyoffice) ServeHTTP(w http.ResponseWriter, r *http.Request) {
g.mux.ServeHTTP(w, r)
}