Skip to content

Commit

Permalink
initial prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
Blacksmoke16 committed Dec 30, 2018
1 parent 70f569d commit 2439411
Show file tree
Hide file tree
Showing 20 changed files with 779 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.cr]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/docs/
/lib/
/bin/
/.shards/
*.dwarf

# Libraries don't need dependency lock
# Dependencies will be locked in application that uses them
/shard.lock
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: crystal
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 your-name-here

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# athena

TODO: Write a description here
Annotation based web framework with built in param conversion.

## Installation

1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
athena:
github: your-github-user/athena
github: Blacksmoke16/athena
```
2. Run `shards install`

Expand All @@ -26,12 +26,12 @@ TODO: Write development instructions here

## Contributing

1. Fork it (<https://github.com/your-github-user/athena/fork>)
1. Fork it (<https://github.com/Blacksmoke16/athena/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Contributors

- [your-name-here](https://github.com/your-github-user) - creator and maintainer
- [Blacksmoke16](https://github.com/Blacksmoke16) Blacksmoke16 - creator, maintainer
19 changes: 19 additions & 0 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: athena

description: |
Annotation based web framework with built in param conversion.
version: 0.1.0

authors:
- Blacksmoke16 <[email protected]>

crystal: 0.27.0

license: MIT

dependencies:
CrSerializer:
github: blacksmoke16/CrSerializer
radix:
github: luislavena/radix
33 changes: 33 additions & 0 deletions spec/controllers/athena_controller.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class AthenaController < Athena::ClassController
@[Athena::Get(path: "noParamsGet")]
def self.noParamsGet : String
"foobar"
end

@[Athena::Get(path: "double/:val1/:val2")]
def self.doubleParams(val1 : Int32, val2 : Int32) : Int32
it "should run correctly" do
val1.should be_a Int32
val2.should be_a Int32
val1.should eq 1000
val2.should eq 9000
end
val1 + val2
end

@[Athena::Post(path: "noParamsPost")]
def self.noParamsPost : String
"foobar"
end

@[Athena::Post(path: "double/:val")]
def self.doubleParamsPost(val1 : Int32, val2 : Int32) : Int32
it "should run correctly" do
val1.should be_a Int32
val2.should be_a Int32
val1.should eq 750
val2.should eq 250
end
val1 + val2
end
end
19 changes: 19 additions & 0 deletions spec/controllers/bool_controller.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class BoolController < Athena::ClassController
@[Athena::Get(path: "bool/:val")]
def self.bool(val : Bool) : Bool
it "should run correctly" do
val.should be_a Bool
val.should eq true
end
val
end

@[Athena::Post(path: "bool")]
def self.boolPost(val : Bool) : Bool
it "should run correctly" do
val.should be_a Bool
val.should eq true
end
val
end
end
37 changes: 37 additions & 0 deletions spec/controllers/float_controller.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class FloatController < Athena::ClassController
@[Athena::Get(path: "float32/:num")]
def self.float32(num : Float32) : Float32
it "should run correctly" do
num.should be_a Float32
num.should eq -2342.223_f32
end
num
end

@[Athena::Post(path: "float32/")]
def self.float32Post(num : Float32) : Float32
it "should run correctly" do
num.should be_a Float32
num.should eq -2342.223_f32
end
num
end

@[Athena::Get(path: "float64/:num")]
def self.float64(num : Float64) : Float64
it "should run correctly" do
num.should be_a Float64
num.should eq 2342.234234234223
end
num
end

@[Athena::Post(path: "float64")]
def self.float64Post(num : Float64) : Float64
it "should run correctly" do
num.should be_a Float64
num.should eq 2342.234234234223
end
num
end
end
181 changes: 181 additions & 0 deletions spec/controllers/int_controller.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
class IntController < Athena::ClassController
@[Athena::Get(path: "int8/:num")]
def self.int8(num : Int8) : Int8
it "should run correctly" do
num.should be_a Int8
num.should eq 123
end
num
end

@[Athena::Post(path: "int8")]
def self.int8Post(num : Int8) : Int8
it "should run correctly" do
num.should be_a Int8
num.should eq 123
end
num
end

@[Athena::Get(path: "int16/:num")]
def self.int16(num : Int16) : Int16
it "should run correctly" do
num.should be_a Int16
num.should eq 456
end
num
end

@[Athena::Post(path: "int16/")]
def self.int16Post(num : Int16) : Int16
it "should run correctly" do
num.should be_a Int16
num.should eq 456
end
num
end

@[Athena::Get(path: "int32/:num")]
def self.int32(num : Int32) : Int32
it "should run correctly" do
num.should be_a Int32
num.should eq 111111
end
num
end

@[Athena::Post(path: "int32")]
def self.int32Post(num : Int32) : Int32
it "should run correctly" do
num.should be_a Int32
num.should eq 111111
end
num
end

@[Athena::Get(path: "int64/:num")]
def self.int64(num : Int64) : Int64
it "should run correctly" do
num.should be_a Int64
num.should eq 9999999999999999
end
num
end

@[Athena::Post(path: "int64")]
def self.int64Post(num : Int64) : Int64
it "should run correctly" do
num.should be_a Int64
num.should eq 9999999999999999
end
num
end

# @[Athena::Get(path: "int128/:num")]
# def self.int128(num : Int128) : Int128
# it "should run correctly" do
# num.should be_a Int128
# num.should eq 9999999999999999
# end
# num
# end

# @[Athena::Post(path: "int128/:num")]
# def self.int128Post(num : Int128) : Int128
# it "should run correctly" do
# num.should be_a Int128
# num.should eq 9999999999999999
# end
# num
# end

@[Athena::Get(path: "uint8/:num")]
def self.uint8(num : UInt8) : UInt8
it "should run correctly" do
num.should be_a UInt8
num.should eq 123
end
num
end

@[Athena::Post(path: "uint8/")]
def self.uint8Post(num : UInt8) : UInt8
it "should run correctly" do
num.should be_a UInt8
num.should eq 123
end
num
end

@[Athena::Get(path: "uint16/:num")]
def self.uint16(num : UInt16) : UInt16
it "should run correctly" do
num.should be_a UInt16
num.should eq 456
end
num
end

@[Athena::Post(path: "uint16")]
def self.uint1Post(num : UInt16) : UInt16
it "should run correctly" do
num.should be_a UInt16
num.should eq 456
end
num
end

@[Athena::Get(path: "uint32/:num")]
def self.uint32(num : UInt32) : UInt32
it "should run correctly" do
num.should be_a UInt32
num.should eq 111111
end
num
end

@[Athena::Post(path: "uint32")]
def self.uint32Post(num : UInt32) : UInt32
it "should run correctly" do
num.should be_a UInt32
num.should eq 111111
end
num
end

@[Athena::Get(path: "uint64/:num")]
def self.uint64(num : UInt64) : UInt64
it "should run correctly" do
num.should be_a UInt64
num.should eq 9999999999999999
end
num
end

@[Athena::Post(path: "uint64/")]
def self.uint64Post(num : UInt64) : UInt64
it "should run correctly" do
num.should be_a UInt64
num.should eq 9999999999999999
end
num
end

# @[Athena::Get(path: "uint128/:num")]
# def self.uint128(num : UInt128) : UInt128
# it "should run correctly" do
# num.should be_a UInt128
# num.should eq 9999999999999999
# end
# num
# end

# @[Athena::Post(path: "uint128")]
# def self.uint128Post(num : UInt128) : UInt128
# it "should run correctly" do
# num.should be_a UInt128
# num.should eq 9999999999999999
# end
# num
# end
end
19 changes: 19 additions & 0 deletions spec/controllers/string_controller.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class StringController < Athena::ClassController
@[Athena::Get(path: "string/:val")]
def self.string(val : String) : String
it "should run correctly" do
val.should be_a String
val.should eq "sdfsd"
end
val
end

@[Athena::Post(path: "string")]
def self.stringPost(val : String) : String
it "should run correctly" do
val.should be_a String
val.should eq "sdfsd"
end
val
end
end
Loading

0 comments on commit 2439411

Please sign in to comment.