-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from hahwul/dev
Release v0.10.0
- Loading branch information
Showing
21 changed files
with
241 additions
and
18 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: noir | ||
version: 0.9.1 | ||
version: 0.10.0 | ||
|
||
authors: | ||
- hahwul <[email protected]> | ||
|
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 @@ | ||
[package] | ||
name = "example-hello-world" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
axum = { path = "../../axum" } | ||
tokio = { version = "1.0", features = ["full"] } |
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,19 @@ | ||
use axum::{response::Html, routing::get, Router}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let app = Router::new() | ||
.route("/", get(handler)) | ||
.route("/foo", get(handler)) | ||
.route("/bar", post(handler)); | ||
|
||
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000") | ||
.await | ||
.unwrap(); | ||
println!("listening on {}", listener.local_addr().unwrap()); | ||
axum::serve(listener, app).await.unwrap(); | ||
} | ||
|
||
async fn handler() -> Html<&'static str> { | ||
Html("<h1>Hello, World!</h1>") | ||
} |
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,12 @@ | ||
require "../func_spec.cr" | ||
|
||
extected_endpoints = [ | ||
Endpoint.new("/", "GET"), | ||
Endpoint.new("/foo", "GET"), | ||
Endpoint.new("/bar", "POST"), | ||
] | ||
|
||
FunctionalTester.new("fixtures/rust_axum/", { | ||
:techs => 1, | ||
:endpoints => 3, | ||
}, extected_endpoints).test_all |
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
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
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
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
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
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,49 @@ | ||
require "../../models/analyzer" | ||
|
||
class AnalyzerRustAxum < Analyzer | ||
def analyze | ||
# Source Analysis | ||
pattern = /\.route\("([^"]+)",\s*([^)]+)\)/ | ||
|
||
begin | ||
Dir.glob("#{base_path}/**/*") do |path| | ||
next if File.directory?(path) | ||
|
||
if File.exists?(path) && File.extname(path) == ".rs" | ||
File.open(path, "r", encoding: "utf-8", invalid: :skip) do |file| | ||
file.each_line do |line| | ||
if line.includes? ".route(" | ||
match = line.match(pattern) | ||
if match | ||
begin | ||
route_argument = match[1] | ||
callback_argument = match[2] | ||
result << Endpoint.new("#{@url}#{route_argument}", callback_to_method(callback_argument)) | ||
rescue | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
rescue e | ||
end | ||
|
||
result | ||
end | ||
|
||
def callback_to_method(str) | ||
method = str.split("(").first | ||
if !["get", "post", "put", "delete"].includes?(method) | ||
method = "get" | ||
end | ||
|
||
method.upcase | ||
end | ||
end | ||
|
||
def analyzer_rust_axum(options : Hash(Symbol, String)) | ||
instance = AnalyzerRustAxum.new(options) | ||
instance.analyze | ||
end |
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
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
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
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
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,15 @@ | ||
require "../../models/detector" | ||
|
||
class DetectorRustAxum < Detector | ||
def detect(filename : String, file_contents : String) : Bool | ||
check = file_contents.includes?("axum") | ||
check = check && file_contents.includes?("dependencies") | ||
check = check && filename.includes?("Cargo.toml") | ||
|
||
check | ||
end | ||
|
||
def set_name | ||
@name = "rust_axum" | ||
end | ||
end |
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
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
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
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
Oops, something went wrong.