2021-05-09 14:06:06 +02:00
|
|
|
package instance
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"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
|
|
|
}
|
|
|
|
|
|
|
|
// New returns a new instance information module
|
2021-10-11 14:37:33 +02:00
|
|
|
func New(config *config.Config, processor processing.Processor) api.ClientModule {
|
2021-05-09 14:06:06 +02: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 16:35:57 +02:00
|
|
|
s.AttachHandler(http.MethodPatch, InstanceInformationPath, m.InstanceUpdatePATCHHandler)
|
2021-05-09 14:06:06 +02:00
|
|
|
return nil
|
|
|
|
}
|