Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating this route method give me page not found error ? #284

Open
DiwakarThapa opened this issue Jul 5, 2019 · 0 comments
Open

Creating this route method give me page not found error ? #284

DiwakarThapa opened this issue Jul 5, 2019 · 0 comments

Comments

@DiwakarThapa
Copy link

DiwakarThapa commented Jul 5, 2019

routes.add(method: .post, uri: "api/login") { (request, response) in
let error:[String:Any] = [
"error":"Login Error",
"message":"Invalid user name or password"
]
response.setHeader(.contentType, value: "text/json")
guard let username = request.header(HTTPRequestHeader.Name.custom(name: "username")),
username == "[email protected]",
let password = request.header(HTTPRequestHeader.Name.custom(name: "password")),
password == "admin123" else {
try! response.setBody(json: error).completed(status: .unauthorized)
return
}
let successResponse:[String:Any] = [
"profile": [
"username":"Admin123",
"description":"he is admin",
"age":24,
"image":"https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=2ahUKEwii87ilrp3jAhVr73MBHdtzADAQjRx6BAgBEAU&url=https%3A%2F%2Fwww.iconfinder.com%2Ficons%2F329322%2Fadmin_avatar_men_people_person_profile_user_icon&psig=AOvVaw1cJsBF1hE8dpQli9v5FDpK&ust=1562401763853297"
]
]
try! response.setBody(json: successResponse).completed()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant