mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-23 18:52:11 +00:00
8c9a853343
Allow admins to set instance settings through a PATCH to /api/v1/instance Update templates to reflect some of the new fields
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package instance
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/superseriousbusiness/gotosocial/internal/api"
|
|
"github.com/superseriousbusiness/gotosocial/internal/config"
|
|
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
|
"github.com/superseriousbusiness/gotosocial/internal/router"
|
|
)
|
|
|
|
const (
|
|
// InstanceInformationPath is for serving instance info requests
|
|
InstanceInformationPath = "api/v1/instance"
|
|
)
|
|
|
|
// Module implements the ClientModule interface
|
|
type Module struct {
|
|
config *config.Config
|
|
processor processing.Processor
|
|
log *logrus.Logger
|
|
}
|
|
|
|
// New returns a new instance information module
|
|
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
|
|
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)
|
|
s.AttachHandler(http.MethodPatch, InstanceInformationPath, m.InstanceUpdatePATCHHandler)
|
|
return nil
|
|
}
|