@@ -25,6 +25,7 @@ import (
25
25
"github.com/go-siris/siris/context"
26
26
"github.com/go-siris/siris/core/errors"
27
27
"github.com/go-siris/siris/core/host"
28
+ "github.com/go-siris/siris/core/nettools"
28
29
"github.com/go-siris/siris/core/router"
29
30
"github.com/go-siris/siris/view"
30
31
)
@@ -48,6 +49,7 @@ func TestSiris(t *testing.T) {
48
49
initial ()
49
50
50
51
app := Default ()
52
+ app .Configure (WithJSONInteratorReplacement , EnableReuseport , EnableQUICSupport , WithTimeFormat (time .RFC3339 ), WithCharset ("UTF-8" ), WithRemoteAddrHeader ("X-Real-Ip" ), WithoutRemoteAddrHeader ("X-No-Real-Ip" ), WithOtherValue ("AppName" , "SIRIS" ))
51
53
app .AttachView (view .HTML ("./" , ".html" ).Binary (get_files , get_names ))
52
54
53
55
app .OnErrorCode (StatusPaymentRequired , func (ctx context.Context ) {
@@ -69,7 +71,7 @@ func TestSiris(t *testing.T) {
69
71
})
70
72
71
73
app .Favicon (staticDir )
72
- app .Get ("/view" , func (ctx context.Context ) {
74
+ app .Get ("/view" , context . LimitRequestBodySize ( 1234567890 ), func (ctx context.Context ) {
73
75
ctx .View ("view/parent.html" )
74
76
})
75
77
app .Get ("/" , func (ctx context.Context ) {
@@ -237,6 +239,11 @@ func TestSiris(t *testing.T) {
237
239
ctx .StatusCode (StatusPaymentRequired )
238
240
})
239
241
242
+ app .Get ("/get-gzip" , func (ctx context.Context ) {
243
+ ctx .Gzip (ctx .ClientSupportsGzip ())
244
+ ctx .Text ("Gzip" )
245
+ })
246
+
240
247
go func () {
241
248
ch := make (chan os.Signal , 1 )
242
249
signal .Notify (ch ,
@@ -280,6 +287,13 @@ func TestSiris(t *testing.T) {
280
287
go app .Run (TLS ("go-siris.com:9443" , sslCert , sslKey ), WithoutBanner , WithoutInterruptHandler )
281
288
}
282
289
290
+ unicl , err := nettools .UNIX ("/tmp/srv.sock" , 0777 ) // see its code to see how you can manually create a new file listener, it's easy.
291
+ if err != nil {
292
+ panic (err )
293
+ }
294
+
295
+ go app .Run (Listener (unicl ))
296
+
283
297
loggerP .Write ([]byte ("Logger: Servers started" ))
284
298
285
299
time .Sleep (time .Duration (5 * time .Second ))
@@ -315,8 +329,10 @@ func configureHosts(su *host.Supervisor) {
315
329
su .RegisterOnErrorHook (func (err error ) {
316
330
println ("error:" + err .Error ())
317
331
})
318
- su .RegisterOnServeHook (func (_ host.TaskHost ) {
332
+ su .RegisterOnServeHook (func (th host.TaskHost ) {
319
333
println ("Server Started" )
334
+ println (th .HostURL ())
335
+ println (th .Hostname ())
320
336
})
321
337
// su.RegisterOnError
322
338
// su.RegisterOnServe
@@ -502,4 +518,5 @@ func testClient(e *httpexpect.Expect) {
502
518
e .GET ("/favicon.ico" ).Expect ().Status (StatusOK )
503
519
504
520
e .GET ("/get-payment" ).Expect ().Status (StatusPaymentRequired )
521
+ e .GET ("/get-gzip" ).Expect ().Status (StatusOK )
505
522
}
0 commit comments