2021-05-09 13:06:06 +01:00
|
|
|
package instance
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/api"
|
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 {
|
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-12-07 12:31:39 +00:00
|
|
|
func New(processor processing.Processor) api.ClientModule {
|
2021-05-09 13:06:06 +01:00
|
|
|
return &Module{
|
|
|
|
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
|
|
|
|
}
|