generated from VLADIMIR/template
add images
This commit is contained in:
parent
4ae2715ab0
commit
ae82f8e0d9
@ -165,9 +165,10 @@ message Action {
|
|||||||
string place = 2;
|
string place = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string text = 4;
|
string text = 4;
|
||||||
repeated Application applications = 5;
|
string image = 5;
|
||||||
bool hidden = 6;
|
repeated Application applications = 6;
|
||||||
repeated Door doors = 7;
|
bool hidden = 7;
|
||||||
|
repeated Door doors = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetGameReq {}
|
message GetGameReq {}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -139,6 +140,19 @@ func main() {
|
|||||||
log.Fatalln(http.ListenAndServe(config.ClientPort, muxUser))
|
log.Fatalln(http.ListenAndServe(config.ClientPort, muxUser))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
dir := "./data/story/images"
|
||||||
|
// Создаем файловый сервер
|
||||||
|
fs := http.FileServer(http.Dir(dir))
|
||||||
|
|
||||||
|
// Добавляем middleware для логирования
|
||||||
|
http.Handle("/", loggingMiddleware(fs))
|
||||||
|
|
||||||
|
log.Println("Файловый сервер запущен на http://localhost:8120")
|
||||||
|
log.Println("Обслуживается директория: " + dir)
|
||||||
|
log.Fatal(http.ListenAndServe(":8120", nil))
|
||||||
|
}()
|
||||||
|
|
||||||
muxAdmin := http.NewServeMux()
|
muxAdmin := http.NewServeMux()
|
||||||
subAdminFS, err := fs.Sub(adminFS, "static/admin")
|
subAdminFS, err := fs.Sub(adminFS, "static/admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -163,3 +177,14 @@ func cors(h http.Handler) http.Handler {
|
|||||||
h.ServeHTTP(w, r)
|
h.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loggingMiddleware(next http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
|
// Логируем запрос
|
||||||
|
log.Printf("[%s] %s %s", r.Method, r.URL.Path, time.Since(start))
|
||||||
|
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ type Place struct {
|
|||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
|
Image string `json:"image"`
|
||||||
Applications []*Application `json:"applications,omitempty"`
|
Applications []*Application `json:"applications,omitempty"`
|
||||||
Hidden bool `json:"hidden"`
|
Hidden bool `json:"hidden"`
|
||||||
Doors []*Door `json:"doors"`
|
Doors []*Door `json:"doors"`
|
||||||
@ -36,6 +37,13 @@ func NewClientErrorPlace(code string) *Place {
|
|||||||
|
|
||||||
type PlaceOpt func(place *Place) error
|
type PlaceOpt func(place *Place) error
|
||||||
|
|
||||||
|
func WithPlaceImage(image string) PlaceOpt {
|
||||||
|
return func(place *Place) error {
|
||||||
|
place.Image = image
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func WithPlaceApplication(applications ...*Application) PlaceOpt {
|
func WithPlaceApplication(applications ...*Application) PlaceOpt {
|
||||||
return func(place *Place) error {
|
return func(place *Place) error {
|
||||||
for _, application := range applications {
|
for _, application := range applications {
|
||||||
|
|||||||
@ -77,6 +77,7 @@ func (s *StoryService) GetPlace(code string) *models.Place {
|
|||||||
place.Code,
|
place.Code,
|
||||||
place.Name,
|
place.Name,
|
||||||
s.cleaner.ClearText(place.Text),
|
s.cleaner.ClearText(place.Text),
|
||||||
|
models.WithPlaceImage(place.Image),
|
||||||
models.WithPlaceApplication(applications...),
|
models.WithPlaceApplication(applications...),
|
||||||
models.WithPlaceHidden(place.Hidden),
|
models.WithPlaceHidden(place.Hidden),
|
||||||
models.WithPlaceDoors(doors...),
|
models.WithPlaceDoors(doors...),
|
||||||
|
|||||||
@ -824,9 +824,10 @@ type Action struct {
|
|||||||
Place string `protobuf:"bytes,2,opt,name=place,proto3" json:"place,omitempty"`
|
Place string `protobuf:"bytes,2,opt,name=place,proto3" json:"place,omitempty"`
|
||||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
||||||
Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"`
|
Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"`
|
||||||
Applications []*Application `protobuf:"bytes,5,rep,name=applications,proto3" json:"applications,omitempty"`
|
Image string `protobuf:"bytes,5,opt,name=image,proto3" json:"image,omitempty"`
|
||||||
Hidden bool `protobuf:"varint,6,opt,name=hidden,proto3" json:"hidden,omitempty"`
|
Applications []*Application `protobuf:"bytes,6,rep,name=applications,proto3" json:"applications,omitempty"`
|
||||||
Doors []*Door `protobuf:"bytes,7,rep,name=doors,proto3" json:"doors,omitempty"`
|
Hidden bool `protobuf:"varint,7,opt,name=hidden,proto3" json:"hidden,omitempty"`
|
||||||
|
Doors []*Door `protobuf:"bytes,8,rep,name=doors,proto3" json:"doors,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@ -889,6 +890,13 @@ func (x *Action) GetText() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *Action) GetImage() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Image
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (x *Action) GetApplications() []*Application {
|
func (x *Action) GetApplications() []*Application {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Applications
|
return x.Applications
|
||||||
@ -1745,15 +1753,16 @@ const file_main_proto_rawDesc = "" +
|
|||||||
"\aactions\x18\x02 \x03(\v2\x1f.crabs.evening_detective.ActionR\aactions\"$\n" +
|
"\aactions\x18\x02 \x03(\v2\x1f.crabs.evening_detective.ActionR\aactions\"$\n" +
|
||||||
"\fAddActionReq\x12\x14\n" +
|
"\fAddActionReq\x12\x14\n" +
|
||||||
"\x05place\x18\x01 \x01(\tR\x05place\"\x0e\n" +
|
"\x05place\x18\x01 \x01(\tR\x05place\"\x0e\n" +
|
||||||
"\fAddActionRsp\"\xed\x01\n" +
|
"\fAddActionRsp\"\x83\x02\n" +
|
||||||
"\x06Action\x12\x0e\n" +
|
"\x06Action\x12\x0e\n" +
|
||||||
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" +
|
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" +
|
||||||
"\x05place\x18\x02 \x01(\tR\x05place\x12\x12\n" +
|
"\x05place\x18\x02 \x01(\tR\x05place\x12\x12\n" +
|
||||||
"\x04name\x18\x03 \x01(\tR\x04name\x12\x12\n" +
|
"\x04name\x18\x03 \x01(\tR\x04name\x12\x12\n" +
|
||||||
"\x04text\x18\x04 \x01(\tR\x04text\x12H\n" +
|
"\x04text\x18\x04 \x01(\tR\x04text\x12\x14\n" +
|
||||||
"\fapplications\x18\x05 \x03(\v2$.crabs.evening_detective.ApplicationR\fapplications\x12\x16\n" +
|
"\x05image\x18\x05 \x01(\tR\x05image\x12H\n" +
|
||||||
"\x06hidden\x18\x06 \x01(\bR\x06hidden\x123\n" +
|
"\fapplications\x18\x06 \x03(\v2$.crabs.evening_detective.ApplicationR\fapplications\x12\x16\n" +
|
||||||
"\x05doors\x18\a \x03(\v2\x1d.crabs.evening_detective.DoorR\x05doors\"\f\n" +
|
"\x06hidden\x18\a \x01(\bR\x06hidden\x123\n" +
|
||||||
|
"\x05doors\x18\b \x03(\v2\x1d.crabs.evening_detective.DoorR\x05doors\"\f\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"GetGameReq\"R\n" +
|
"GetGameReq\"R\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
|
|||||||
@ -397,6 +397,9 @@
|
|||||||
"text": {
|
"text": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"image": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"applications": {
|
"applications": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user