wip #39
41 fail, 528 pass in 1s
569 tests 528 ✅ 1s ⏱️
54 suites 0 💤
1 files 41 ❌
Results for commit 96afe78.
Annotations
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group> (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-20.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
class HelloHandler
super Handler
redef fun get(req, res) do res.html "<h1>Hello World!</h1>"
end
var app = new App
app.use("/", new HelloHandler)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#5 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-24.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
import template
class QueryStringHandler
super Handler
redef fun get(req, res) do
var tpl = new Template
tpl.addn "URI: {req.uri}"
tpl.addn "Query string: {req.query_string}"
for name, arg in req.get_args do
tpl.addn "{name}: {arg}"
end
res.send tpl
end
end
var app = new App
app.use("/", new QueryStringHandler)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#6 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-25.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
import template
class PostHandler
super Handler
redef fun post(req, res) do
var tpl = new Template
tpl.addn "URI: {req.uri}"
tpl.addn "Body: {req.body}"
for name, arg in req.post_args do
tpl.addn "{name}: {arg}"
end
res.send tpl
end
end
var app = new App
app.use("/", new PostHandler)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#10 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-29.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
class UserHome
super Handler
redef fun get(req, res) do
var user = req.param("user")
if user != null then
res.send "Hello {user}"
else
res.send("Nothing received", 400)
end
end
end
var app = new App
app.use("/:user", new UserHome)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#11 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-30.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
class UserItem
super Handler
redef fun get(req, res) do
var user = req.param("user")
var item = req.param("item")
if user == null or item == null then
res.send("Nothing received", 400)
else
res.send "Here the item {item} of the use {user}."
end
end
end
var app = new App
app.use("/user/:user/item/:item/*", new UserItem)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#12 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-31.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
class MyLogger
super Handler
redef fun all(req, res) do print "Request Logged!"
end
class HelloHandler
super Handler
redef fun get(req, res) do res.send "Hello World!"
end
var app = new App
app.use_before("/*", new MyLogger)
app.use("/", new HelloHandler)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#13 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-32.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
import realtime
redef class HttpRequest
# Time that request was received by the Popcorn app.
var timer: nullable Clock = null
end
class RequestTimeHandler
super Handler
redef fun all(req, res) do req.timer = new Clock
end
class LogHandler
super Handler
redef fun all(req, res) do
var timer = req.timer
if timer != null then
print "{req.method} {req.uri} {res.color_status} ({timer.total}s)"
else
print "{req.method} {req.uri} {res.color_status}"
end
end
end
class HelloHandler
super Handler
redef fun get(req, res) do res.send "Hello World!"
end
var app = new App
app.use_before("/*", new RequestTimeHandler)
app.use("/", new HelloHandler)
app.use_after("/*", new LogHandler)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#14 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-33.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
class AppHome
super Handler
redef fun get(req, res) do res.send "Site Home"
end
class UserLogger
super Handler
redef fun all(req, res) do print "User logged"
end
class UserHome
super Handler
redef fun get(req, res) do res.send "User Home"
end
class UserProfile
super Handler
redef fun get(req, res) do res.send "User Profile"
end
var user_router = new Router
user_router.use("/*", new UserLogger)
user_router.use("/", new UserHome)
user_router.use("/profile", new UserProfile)
var app = new App
app.use("/", new AppHome)
app.use("/user", user_router)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#15 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-34.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
class SimpleErrorHandler
super Handler
redef fun all(req, res) do
if res.status_code != 200 then
print "An error occurred! {res.status_code})"
end
end
end
class HelloHandler
super Handler
redef fun get(req, res) do res.send "Hello World!"
end
var app = new App
app.use("/", new HelloHandler)
app.use("/*", new SimpleErrorHandler)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#16 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-35.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
import template
class HtmlErrorTemplate
super Template
var status: Int
var message: nullable String
redef fun rendering do add """
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{{message or else status}}}</title>
</head>
<body>
<h1>{{{status}}} {{{message or else ""}}}</h1>
</body>
</html>"""
end
class HtmlErrorHandler
super Handler
redef fun all(req, res) do
if res.status_code != 200 then
res.send(new HtmlErrorTemplate(res.status_code, "An error occurred!"))
end
end
end
var app = new App
app.use("/*", new HtmlErrorHandler)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#17 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-36.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
redef class Session
var is_logged = false
end
class AppLogin
super Handler
redef fun get(req, res) do
res.html """
<p>Is logged: {{{req.session.as(not null).is_logged}}}</p>
<form action="/" method="POST">
<input type="submit" value="Login" />
</form>"""
end
redef fun post(req, res) do
req.session.as(not null).is_logged = true
res.redirect("/")
end
end
var app = new App
app.use_before("/*", new SessionInit)
app.use("/", new AppLogin)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#18 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-37.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
Error: dev package for `libmongoc-1.0` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
import mongodb
import template
class UserList
super Handler
var db: MongoDb
redef fun get(req, res) do
var users = db.collection("users").find_all(new JsonObject)
var tpl = new Template
tpl.add "<h1>Users</h1>"
tpl.add "<table>"
for user in users do
tpl.add """<tr>
<td>{{{user["login"] or else "null"}}}</td>
<td>{{{user["password"] or else "null"}}}</td>
</tr>"""
end
tpl.add "</table>"
res.html tpl
end
end
class UserForm
super Handler
var db: MongoDb
redef fun get(req, res) do
var tpl = new Template
tpl.add """<h1>Add a new user</h1>
<form action="/new" method="POST">
<input type="text" name="login" />
<input type="password" name="password" />
<input type="submit" value="save" />
</form>"""
res.html tpl
end
redef fun post(req, res) do
var json = new JsonObject
json["login"] = req.post_args["login"]
json["password"] = req.post_args["password"]
db.collection("users").insert(json)
res.redirect "/"
end
end
var mongo = new MongoClient("mongodb://mongo:27017/")
var db = mongo.database("mongo_example")
var app = new App
app.use("/", new UserList(db))
app.use("/new", new UserForm(db))
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.popcorn.<group>
github-actions / nitunit-some Results
<group>#19 (nitunit.popcorn.popcorn.<group>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/popcorn-38.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
var app = new App
app.use("/*", new StaticHandler("my-ng-app/", "index.html"))
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn::pop_auth.<module>
github-actions / nitunit-some Results
<module> (nitunit.popcorn::pop_auth.<module>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/pop_auth-3.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
Error: dev package for `libcurl` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
import popcorn::pop_auth
class ProfileHandler
super Handler
redef fun get(req, res) do
var session = req.session
if session == null then
res.send "No session :("
return
end
var user = session.user
if user == null then
res.send "Not logged in"
return
end
res.send "<h1>Hello {user.login}</h1>"
end
end
var client_id = "github client id"
var client_secret = "github client secret"
var app = new App
app.use("/*", new SessionInit)
app.use("/login", new GithubLogin(client_id))
app.use("/oauth", new GithubOAuthCallBack(client_id, client_secret))
app.use("/logout", new GithubLogout)
app.use("/profile", new ProfileHandler)
app.listen("localhost", 3000)
app.use("/api/user", new GithubUser)
Check warning on line 0 in nitunit.popcorn::pop_config.<module>
github-actions / nitunit-some Results
<module> (nitunit.popcorn::pop_config.<module>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/pop_config-4.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
import popcorn::pop_config
# Build config from options
var config = new AppConfig
config.parse_options(args)
# Use options
var app = new App
app.listen(config.app_host, config.app_port)
Check warning on line 0 in nitunit.popcorn::pop_config.<module>
github-actions / nitunit-some Results
<module>#2 (nitunit.popcorn::pop_config.<module>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/pop_config-5.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
import popcorn::pop_config
class MyConfig
super AppConfig
# My secret code I don't want to share in my source repository
fun secret: String do return opt_secret.value or else ini["secret"] or else "my-secret"
# opt --secret
var opt_secret = new OptionString("My secret string", "--secret")
redef init do
super
add_option opt_secret
end
end
class SecretHandler
super Handler
# Config to use to access `secret`
var config: MyConfig
redef fun get(req, res) do
res.send config.secret
end
end
var config = new MyConfig
config.parse_options(args)
var app = new App
app.use("/secret", new SecretHandler(config))
app.listen(config.app_host, config.app_port)
Check warning on line 0 in nitunit.popcorn.AppConfig
github-actions / nitunit-some Results
<class> (nitunit.popcorn.AppConfig) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/pop_config-6.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
import popcorn::pop_config
# Build config from default values
var config = new AppConfig
config.parse_options(args)
# Change config values
config.ini["app.port"] = 3001.to_s
# Use options
var app = new App
app.listen(config.app_host, config.app_port)
Check warning on line 0 in nitunit.popcorn.RepoObject
github-actions / nitunit-some Results
<class> (nitunit.popcorn.RepoObject) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/pop_repos-3.nit
Error: dev package for `libmongoc-1.0` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn::pop_repos
class Album
super RepoObject
serialize
var title: String
var price: Float
end
Check warning on line 0 in nitunit.popcorn.RepoObject
github-actions / nitunit-some Results
<class>#2 (nitunit.popcorn.RepoObject) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/pop_repos-4.nit
Error: dev package for `libmongoc-1.0` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn::pop_repos
class Order
super RepoObject
serialize
redef var id = "order-{get_time}"
# ...
end
Check warning on line 0 in nitunit.popcorn::pop_sessions.<module>
github-actions / nitunit-some Results
<module> (nitunit.popcorn::pop_sessions.<module>) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/pop_sessions-3.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
redef class Session
var is_logged = false
end
class AppLogin
super Handler
redef fun get(req, res) do
res.html """
<p>Is logged: {{{req.session.as(not null).is_logged}}}</p>
<form action="/" method="POST">
<input type="submit" value="Login" />
</form>"""
end
redef fun post(req, res) do
req.session.as(not null).is_logged = true
res.redirect("/")
end
end
var app = new App
app.use_before("/*", new SessionInit)
app.use("/", new AppLogin)
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.SessionInit
github-actions / nitunit-some Results
<class> (nitunit.popcorn.SessionInit) failed
nitunit.xml [took 0s]
Raw output
Compilation error in nitunit.out/pop_sessions-4.nit
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
import popcorn
var app = new App
app.use_before("/*", new SessionInit)
# ... other middlewares
app.listen("localhost", 3000)
Check warning on line 0 in nitunit.popcorn.TestExampleAngular
github-actions / nitunit-some Results
test_example_angular (nitunit.popcorn.TestExampleAngular) failed
nitunit.xml [took 0s]
Raw output
Compilation Error
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
Check warning on line 0 in nitunit.popcorn.TestExamplePostHandler
github-actions / nitunit-some Results
test_example_post_handler (nitunit.popcorn.TestExamplePostHandler) failed
nitunit.xml [took 0s]
Raw output
Compilation Error
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
Check warning on line 0 in nitunit.popcorn.TestExampleQueryString
github-actions / nitunit-some Results
test_example_query_string (nitunit.popcorn.TestExampleQueryString) failed
nitunit.xml [took 0s]
Raw output
Compilation Error
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.
Check warning on line 0 in nitunit.popcorn.TestExampleHello
github-actions / nitunit-some Results
test_example_hello (nitunit.popcorn.TestExampleHello) failed
nitunit.xml [took 0s]
Raw output
Compilation Error
Error: dev package for `libevent` unknown by `pkg-config`, install it with `apt-get`, `brew` or similar.