-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01ecdb6
commit 78fa6be
Showing
10 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <karm-net/router.h> | ||
#include <karm-sys/entry.h> | ||
|
||
namespace Hideo::Chat { | ||
|
||
Strong<Net::App> app() { | ||
return Net::router({ | ||
Net::get( | ||
"/user/:id", | ||
[](Net::Scope const &, Net::Route::Params, Strong<Net::Recv>, Strong<Net::Send>) -> Async::Task<> { | ||
co_return Ok(); | ||
} | ||
), | ||
}); | ||
} | ||
|
||
} // namespace Hideo::Chat | ||
|
||
Async::Task<> entryPointAsync(Sys::Context &) { | ||
return Net::servAsync(Hideo::Chat::app()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://schemas.cute.engineering/stable/cutekit.manifest.component.v1", | ||
"id": "hideo-chat.ws", | ||
"props": { | ||
"cpp-excluded": true | ||
}, | ||
"type": "exe", | ||
"requires": [ | ||
"karm-net" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include <karm-base/res.h> | ||
|
||
namespace Karm::Crypto::_Embed { | ||
|
||
Res<> sRand(MutBytes buf); | ||
|
||
} // namespace Karm::Crypto::_Embed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
namespace Karm::Crypto { | ||
|
||
} // namespace Karm::Crypto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
namespace Karm::Crypto { | ||
|
||
} // namespace Karm::Crypto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Karm Crypto | ||
|
||
"People say not to roll your own crypto... Oh well..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "server.h" | ||
|
||
namespace Karm::Net { | ||
|
||
struct Route { | ||
using Params = Map<String, String>; | ||
|
||
using Handler = Func<Async::Task<>(Scope const &scope, Params params, Strong<Recv> recv, Strong<Send> send)>; | ||
|
||
virtual ~Route() = default; | ||
|
||
virtual bool accept(Scope const &scope) const = 0; | ||
|
||
virtual Async::Task<> handleAsync(Scope const &scope, Strong<Recv> recv, Strong<Send> send) = 0; | ||
}; | ||
|
||
struct HttpRoute : public Route {}; | ||
|
||
Strong<Route> get(Str path, Route::Handler handler); | ||
|
||
Strong<Route> post(Str path, Route::Handler handler); | ||
|
||
Strong<Route> put(Str path, Route::Handler handler); | ||
|
||
Strong<Route> del(Str path, Route::Handler handler); | ||
|
||
struct WsRoute : public Route {}; | ||
|
||
Strong<Route> ws(Str path, Route::Handler handler); | ||
|
||
struct Router : public App { | ||
Vec<Strong<Route>> routes; | ||
}; | ||
|
||
Strong<App> router(Vec<Strong<Route>> routes); | ||
|
||
} // namespace Karm::Net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <karm-base/async.h> | ||
#include <karm-base/func.h> | ||
#include <karm-mime/url.h> | ||
|
||
namespace Karm::Net { | ||
|
||
struct Scope { | ||
enum struct _Type { | ||
WEBSOCKET, | ||
HTTP, | ||
}; | ||
|
||
using enum _Type; | ||
|
||
_Type type; | ||
Mime::Url url; | ||
Map<String, String> headers; | ||
}; | ||
|
||
struct Recv { | ||
}; | ||
|
||
struct Send { | ||
}; | ||
|
||
struct App { | ||
virtual ~App() = default; | ||
virtual Async::Task<> handleAsync(Scope, Strong<Recv>, Strong<Send>) = 0; | ||
}; | ||
|
||
struct ServProps { | ||
}; | ||
|
||
Async::Task<> servAsync(Strong<App> app, ServProps props = {}); | ||
|
||
} // namespace Karm::Net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
namespace Karm::Store { | ||
|
||
struct Query { | ||
}; | ||
|
||
} // namespace Karm::Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
namespace Karm::Store { | ||
|
||
} // namespace Karm::Store |