2021-05-09 14:06:06 +02:00
|
|
|
package instance
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/api"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/config"
|
2021-05-30 13:12:00 +02:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
2021-05-09 14:06:06 +02:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/router"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-05-15 11:58:11 +02:00
|
|
|
// InstanceInformationPath is for serving instance info requests
|
2021-05-09 14:06:06 +02:00
|
|
|
InstanceInformationPath = "api/v1/instance"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Module implements the ClientModule interface
|
|
|
|
type Module struct {
|
|
|
|
config *config.Config
|
2021-05-30 13:12:00 +02:00
|
|
|
processor processing.Processor
|
2021-05-09 14:06:06 +02:00
|
|
|
log *logrus.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
// New returns a new instance information module
|
2021-05-30 13:12:00 +02:00
|
|
|
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
|
2021-05-09 14:06:06 +02:00
|
|
|
return &Module{
|
|
|
|
config: config,
|
|
|
|
processor: processor,
|
|
|
|
log: log,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Route satisfies the ClientModule interface
|
|
|
|
func (m *Module) Route(s router.Router) error {
|
|
|
|
s.AttachHandler(http.MethodGet, InstanceInformationPath, m.InstanceInformationGETHandler)
|
2021-06-23 16:35:57 +02:00
|
|
|
s.AttachHandler(http.MethodPatch, InstanceInformationPath, m.InstanceUpdatePATCHHandler)
|
2021-05-09 14:06:06 +02:00
|
|
|
return nil
|
|
|
|
}
|