MCPcopy Index your code
hub / github.com/Preloading/TwitterAPIBridge / InitServer

Function InitServer

twitterv1/twitterv1.go:20–160  ·  view source on GitHub ↗
(config *config.Config)

Source from the content-addressed store, hash-verified

18)
19
20func InitServer(config *config.Config) {
21 configData = config
22 blueskyapi.InitConfig(configData)
23 engine := html.New("./static", ".html")
24 app := fiber.New(fiber.Config{
25 //DisablePreParseMultipartForm: true,
26 ProxyHeader: func() string {
27 if configData.UseXForwardedFor {
28 return fiber.HeaderXForwardedFor
29 }
30 return ""
31 }(),
32 Views: engine,
33 })
34
35 // Initialize default config
36 app.Use(logger.New())
37
38 // Custom middleware to log request details
39 if config.DeveloperMode {
40 app.Use(func(c *fiber.Ctx) error {
41 // fmt.Println("Request Method:", c.Method())
42 fmt.Println("Request URL:", c.OriginalURL())
43 // fmt.Println("Post Body:", string(c.Body()))
44 // fmt.Println("Headers:", string(c.Request().Header.Header()))
45 // fmt.Println()
46 return c.Next()
47 })
48 }
49
50 // app.Get("/", func(c *fiber.Ctx) error {
51 // return c.SendString("Hello, World!")
52 // Serve static files from the "static" folder
53 app.Static("/favicon.ico", "./static/favicon.ico")
54 app.Static("/robots.txt", "./static/robots.txt")
55 app.Static("/static", "./static")
56
57 // Serve /
58 app.Get("/", func(c *fiber.Ctx) error {
59 // Render index within layouts/nested/main within layouts/nested/base
60 return c.Render("index", fiber.Map{
61 "DeveloperMode": config.DeveloperMode,
62 "NotConfigured": configData.CdnURL == "http://127.0.0.1:3000",
63 "PrefixedURL": "https://" + c.Hostname(),
64 "UnPrefixedURL": c.Hostname(),
65 "Version": config.Version,
66 }, "index")
67 })
68
69 // Auth
70 app.Post("/oauth/access_token", access_token)
71 app.Get("/1/account/verify_credentials.:filetype", VerifyCredentials)
72 app.Get("/account/verify_credentials.:filetype", VerifyCredentials)
73
74 // Tweeting
75 app.Post("/1/statuses/update.:filetype", status_update)
76 app.Post("/1/statuses/update_with_media.:filetype", status_update_with_media)
77

Callers 1

mainFunction · 0.92

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected