This repository has been archived by the owner on Jan 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79de82c
commit e7d4c3c
Showing
12 changed files
with
1,038 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env perl | ||
use Dancer; | ||
use PrimoServices; | ||
dance; |
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,27 @@ | ||
# configuration file for development environment | ||
|
||
# the logger engine to use | ||
# console: log messages to STDOUT (your console where you started the | ||
# application server) | ||
# file: log message to a file in log/ | ||
logger: "console" | ||
|
||
# the log level for this environment | ||
# core is the lowest, it shows Dancer's core log messages as well as yours | ||
# (debug, info, warning and error) | ||
log: "core" | ||
|
||
# should Dancer consider warnings as critical errors? | ||
warnings: 1 | ||
|
||
# should Dancer show a stacktrace when an error is caught? | ||
show_errors: 1 | ||
|
||
# auto_reload is a development and experimental feature | ||
# you should enable it by yourself if you want it | ||
# Module::Refresh is needed | ||
# | ||
# Be aware it's unstable and may cause a memory leak. | ||
# DO NOT EVER USE THIS FEATURE IN PRODUCTION | ||
# OR TINY KITTENS SHALL DIE WITH LOTS OF SUFFERING | ||
auto_reload: 0 |
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,17 @@ | ||
# configuration file for production environment | ||
|
||
# only log warning and error messages | ||
log: "warning" | ||
|
||
# log message to a file in logs/ | ||
logger: "file" | ||
|
||
# don't consider warnings critical | ||
warnings: 0 | ||
|
||
# hide errors | ||
show_errors: 0 | ||
|
||
# cache route resolution for maximum performance | ||
route_cache: 1 | ||
|
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,64 @@ | ||
package PrimoServices; | ||
use Dancer 1.3132 ':syntax'; | ||
use Dancer::Exception ':all'; | ||
|
||
use PrimoServices::Dispatcher; | ||
|
||
use Time::HiRes(); | ||
use Benchmark(':hireswallclock'); | ||
|
||
# http://semver.org/ | ||
# X.Y.Z (Major.Minor.Patch) | ||
use version; our $VERSION = version->declare("v2.2.0"); | ||
|
||
# | ||
# Route handlers | ||
# | ||
|
||
get qr{.*} => sub { | ||
|
||
my $data; | ||
|
||
# Parse and reply to the request | ||
#$data = PrimoServices::Dispatcher::handle_request(); | ||
|
||
try { | ||
my $execution_time = timeit( 1, sub{ | ||
$data = PrimoServices::Dispatcher::handle_request(); | ||
}); | ||
|
||
# Calculate the total execution time of the call | ||
$data->{appExecutionTime} = sprintf "%.3fs", $execution_time->real; | ||
} | ||
catch { | ||
status 500; | ||
$data->{error} = 'PrimoServices'; | ||
$data->{exception} = $_; | ||
}; | ||
|
||
# Insert the request into the response (in development) | ||
$data->{request} = params if config->{environment} eq 'development'; | ||
|
||
# Delete request_lookup_table (outside development) | ||
delete $data->{request_lookup_table} if config->{environment} ne 'development'; | ||
|
||
# Count requested and returned number of IDs | ||
$data->{totalItems} = param_array 'id'; | ||
$data->{totalItemsReturned} = @{$data->{items}}; | ||
|
||
# Name and version | ||
$data->{appName} = config->{appname} . ' ' . $VERSION->normal(); | ||
|
||
# Set the serializer to either JSONP or JSON | ||
if ( params->{callback} ) { | ||
set serializer => 'JSONP'; | ||
} | ||
else { | ||
set serializer => 'JSON'; | ||
} | ||
|
||
# Serialize... | ||
return $data; | ||
}; | ||
|
||
true; |
Oops, something went wrong.