-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
38 lines (30 loc) · 799 Bytes
/
main.go
File metadata and controls
38 lines (30 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"os"
"github.com/OpenTransports/Paris/api"
"github.com/go-siris/siris"
"github.com/go-siris/siris/context"
)
func main() {
// Create new siris app
app := siris.New()
// Serve medias files
app.StaticWeb("/medias", "./medias")
app.Use(func(ctx context.Context) {
ctx.Header("Access-Control-Allow-Origin", "*")
ctx.Next()
})
// Build api
app.Get("/transports", api.GetTransports)
app.Get("/transports/{transportID:string}", api.GetTransport)
app.Get("/transports/{transportID:string}/route", api.GetTransportRoute)
app.Get("/agencies", api.GetAgencies)
app.Get("/routes", api.GetRoutes)
// Set listening port
var port = os.Getenv("PORT")
if port == "" {
port = "8080"
}
// Run server
app.Run(siris.Addr(":"+port), siris.WithCharset("UTF-8"))
}