|
@@ -13,17 +13,19 @@ import (
|
|
jwt "github.com/dgrijalva/jwt-go"
|
|
jwt "github.com/dgrijalva/jwt-go"
|
|
)
|
|
)
|
|
|
|
|
|
-func New(app rest.IApplication, core any) *Rest {
|
|
|
|
|
|
+func New(app rest.IApplication, core any, responseHeaders map[string]string) *Rest {
|
|
return &Rest{
|
|
return &Rest{
|
|
- app: app,
|
|
|
|
- core: core,
|
|
|
|
|
|
+ app: app,
|
|
|
|
+ core: core,
|
|
|
|
+ responseHeaders: responseHeaders,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
type Rest struct {
|
|
type Rest struct {
|
|
- server rest.IServer
|
|
|
|
- app rest.IApplication
|
|
|
|
- core any
|
|
|
|
|
|
+ server rest.IServer
|
|
|
|
+ app rest.IApplication
|
|
|
|
+ core any
|
|
|
|
+ responseHeaders map[string]string
|
|
}
|
|
}
|
|
|
|
|
|
func (s *Rest) App() rest.IApplication {
|
|
func (s *Rest) App() rest.IApplication {
|
|
@@ -46,6 +48,11 @@ func responseError(w http.ResponseWriter, err rest.IErrorArgs, code int) {
|
|
|
|
|
|
// handle
|
|
// handle
|
|
func (s *Rest) handle(w http.ResponseWriter, r *http.Request) {
|
|
func (s *Rest) handle(w http.ResponseWriter, r *http.Request) {
|
|
|
|
+ // установка заголовков ответа
|
|
|
|
+ for k, v := range s.responseHeaders {
|
|
|
|
+ w.Header().Set(k, v)
|
|
|
|
+ }
|
|
|
|
+
|
|
// Инициализация rest Request
|
|
// Инициализация rest Request
|
|
rr := &RequestIn{
|
|
rr := &RequestIn{
|
|
RequestIn: &rest.RequestIn{
|
|
RequestIn: &rest.RequestIn{
|