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