This shard provides environment detection. The selected environment is configured using CRYSTAL_ENV
environment variable.
Add this to your application's shard.yml
:
dependencies:
local action = json.parse(request.body).config.action | |
http.request { | |
url = 'https://hooks.slack.com/services/...', | |
method = 'POST', | |
data = json.stringify({text = 'Action: '..action}) | |
} | |
return 200 |
struct NamedTuple | |
macro map_keys(tuple, properties) | |
{% begin %} | |
%tuple = {{tuple}} | |
NamedTuple.new( | |
{% for key, value in properties %} | |
{{value.id}}: %tuple[{{key.symbolize}}], | |
{% end %} | |
) | |
{% end %} |
module Logger2 | |
enum Severity | |
DEBUG | |
INFO | |
end | |
abstract def log(severity, message, context) | |
macro using(context, forward = nil) | |
getter logger : Logger2? |
abstract class Logger2 | |
enum Severity | |
DEBUG | |
INFO | |
end | |
abstract def log(severity : Severity, message, context : String) | |
macro bind(*, context = nil, forward = nil) | |
struct LoggerBinding |
# A Logger allow sending logging information to a stream. | |
# Each logger instance is built and binded to a specific | |
# context that is sent on each entry. | |
# | |
# When requesting a logger via `Logger#get` a context needs to be | |
# specified. Context are meant to be dot seperated path as: | |
# `"http.client"`. Class names and modules are translated into that format. | |
# | |
# ``` | |
# class HTTP::Client |
# A Logger allow sending logging information to a stream. | |
# Each logger instance is built and binded to a specific | |
# context that is sent on each entry. | |
# | |
# When requesting a logger via `Logger#get` a context needs to be | |
# specified. Context are meant to be dot seperated path as: | |
# `"http.client"`. Class names and modules are translated into that format. | |
# | |
# ``` | |
# class HTTP::Client |
Try it on https://www.jsonschemavalidator.net/
# $ crystal run -Dpreview_mt synchronized.cr | |
struct Synchronized(T) | |
@lock = Mutex.new | |
getter inner : T | |
def initialize(@inner : T) | |
end |