-
-
Notifications
You must be signed in to change notification settings - Fork 111
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 #99 from karldoenitz/feature-v2.0.0
Feature v2.0.0
- Loading branch information
Showing
3 changed files
with
56 additions
and
26 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 |
---|---|---|
@@ -1,23 +1,27 @@ | ||
package TigoWeb | ||
|
||
// MethodMapping http请求方式的一个映射 | ||
var MethodMapping = map[string]string{ | ||
"get": "Get", | ||
"head": "Head", | ||
"post": "Post", | ||
"put": "Put", | ||
"delete": "Delete", | ||
"connect": "Connect", | ||
"options": "Options", | ||
"trace": "Trace", | ||
"GET": "Get", | ||
"HEAD": "Head", | ||
"POST": "Post", | ||
"PUT": "Put", | ||
"DELETE": "Delete", | ||
"CONNECT": "Connect", | ||
"OPTIONS": "Options", | ||
"TRACE": "Trace", | ||
} | ||
|
||
const Version = "1.6.5" | ||
|
||
// MethodEnum 根据http请求方式获取对应的函数名 | ||
// - httpMethod: http请求方式 | ||
func MethodEnum(httpMethod string) string { | ||
var MethodMapping = map[string]string{ | ||
"get": "Get", | ||
"head": "Head", | ||
"post": "Post", | ||
"put": "Put", | ||
"delete": "Delete", | ||
"connect": "Connect", | ||
"options": "Options", | ||
"trace": "Trace", | ||
"GET": "Get", | ||
"HEAD": "Head", | ||
"POST": "Post", | ||
"PUT": "Put", | ||
"DELETE": "Delete", | ||
"CONNECT": "Connect", | ||
"OPTIONS": "Options", | ||
"TRACE": "Trace", | ||
} | ||
return MethodMapping[httpMethod] | ||
} |
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,26 @@ | ||
package test_case | ||
|
||
import ( | ||
"Tigo/TigoWeb" | ||
"testing" | ||
) | ||
|
||
func TestEncryptDecrypt(t *testing.T) { | ||
originData := "test data" | ||
key := "key" | ||
encryptData, err := TigoWeb.Encrypt([]byte(originData), []byte(key)) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
return | ||
} | ||
decryptData, err := TigoWeb.Decrypt([]byte(encryptData), []byte(key)) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
return | ||
} | ||
if string(decryptData) != originData { | ||
t.Error("data invalid") | ||
return | ||
} | ||
t.Log("success") | ||
} |