tangled
alpha
login
or
join now
kacaii.dev
/
senac-brigade-server
0
fork
atom
wip: currently rewriting the project as a full stack application
tangled.org/kacaii.dev/sigo
gleam
0
fork
atom
overview
issues
1
pulls
pipelines
:poop: disable cors
kacaii.dev
3 months ago
b39f0c75
2efba49a
+24
-23
2 changed files
expand all
collapse all
unified
split
src
app
web.gleam
test
occurrence_test.gleam
+23
-22
src/app/web.gleam
···
16
16
//// - Static file serving from `/static` path
17
17
18
18
import app/web/context
19
19
-
import cors_builder as cors
20
19
import gleam/dynamic/decode
21
21
-
import gleam/http
22
20
import gleam/json
23
21
import gleam/list
24
22
import gleam/string
25
23
import glight
26
24
import pog
27
25
import wisp
26
26
+
27
27
+
// import cors_builder as cors
28
28
+
// import gleam/http
28
29
29
30
/// Middleware that runs before every request.
30
31
/// It sets up the request, and then calls the next handler.
···
39
40
use <- wisp.log_request(request)
40
41
use <- wisp.rescue_crashes()
41
42
use request <- wisp.handle_head(request)
42
42
-
use request <- cors.wisp_middleware(request, cors_config(ctx))
43
43
+
// use request <- cors.wisp_middleware(request, cors_config(ctx))
43
44
44
45
use <- wisp.serve_static(request, under: path, from: ctx.static_directory)
45
46
handler(request)
···
64
65
priv_directory <> "/log"
65
66
}
66
67
67
67
-
fn cors_config(ctx: context.Context) -> cors.Cors {
68
68
-
let config =
69
69
-
cors.new()
70
70
-
|> cors.allow_origin("https://sigo.cbpm.vercel.app")
71
71
-
|> cors.allow_method(http.Get)
72
72
-
|> cors.allow_method(http.Post)
73
73
-
|> cors.allow_method(http.Put)
74
74
-
|> cors.allow_method(http.Delete)
75
75
-
|> cors.allow_method(http.Options)
76
76
-
|> cors.allow_header("authorization")
77
77
-
|> cors.allow_header("content-type")
78
78
-
|> cors.allow_header("origin")
79
79
-
|> cors.allow_credentials()
80
80
-
81
81
-
case ctx.env {
82
82
-
context.Dev -> cors.allow_all_origins(config)
83
83
-
context.Production -> config
84
84
-
}
85
85
-
}
68
68
+
// fn cors_config(ctx: context.Context) -> cors.Cors {
69
69
+
// let config =
70
70
+
// cors.new()
71
71
+
// |> cors.allow_origin("https://sigo.cbpm.vercel.app")
72
72
+
// |> cors.allow_method(http.Get)
73
73
+
// |> cors.allow_method(http.Post)
74
74
+
// |> cors.allow_method(http.Put)
75
75
+
// |> cors.allow_method(http.Delete)
76
76
+
// |> cors.allow_method(http.Options)
77
77
+
// |> cors.allow_header("authorization")
78
78
+
// |> cors.allow_header("content-type")
79
79
+
// |> cors.allow_header("origin")
80
80
+
// |> cors.allow_credentials()
81
81
+
//
82
82
+
// case ctx.env {
83
83
+
// context.Dev -> cors.allow_all_origins(config)
84
84
+
// context.Production -> config
85
85
+
// }
86
86
+
// }
86
87
87
88
pub fn handle_decode_error(
88
89
decode_errors: List(decode.DecodeError),
+1
-1
test/occurrence_test.gleam
···
1
1
-
import app/http_router
2
1
import app/domain/occurrence/category
3
2
import app/domain/occurrence/priority
4
3
import app/domain/occurrence/sql as o_sql
5
4
import app/domain/occurrence/subcategory
5
5
+
import app/http_router
6
6
import app_dev/sql as dev_sql
7
7
import app_test
8
8
import dummy