├── .gitignore ├── .travis.yml ├── Dockerfile ├── Godeps ├── Godeps.json └── Readme ├── LICENSE ├── README.md ├── care_team.go ├── cmd └── ie │ ├── config.go │ └── main.go ├── config ├── indexes.conf ├── multifactor_huddle_config.json └── simple_huddle_config.json ├── controllers ├── code_lookup.go ├── code_lookup_test.go ├── notification_count.go ├── notification_count_test.go └── pie.go ├── docs ├── MITRE_Intervention_Engine_Overview.pdf ├── dev_install.md ├── docker-linux.md ├── docker-mac.md └── huddle_config.md ├── fixtures ├── age-group.json ├── code-lookup.json ├── code_lookup_suppl.json ├── communication-request.json ├── encounter-er-visit.json ├── encounter-inpatient.json ├── encounter-office-visit.json ├── encounter-planned.json ├── encounter-readmission.json ├── huddle.json ├── huddle_config.json ├── huddle_config_bare.json ├── medication-statement.json ├── multi-code-group.json ├── over-an-age-group.json ├── patients.json ├── risk-group.json ├── sample-group-afib.json ├── sample-group-data-bundle.json ├── sample-group-or-codes.json ├── sample-group.json ├── sample-lookup-request-by-code.json ├── sample-lookup-request-by-name.json └── under-an-age-group.json ├── groups ├── group_param.go ├── group_param_test.go ├── group_resolver.go ├── instacount.go └── instacount_test.go ├── huddles ├── huddle.go ├── huddle_config.go ├── huddle_config_test.go ├── huddle_controller.go ├── huddle_member.go ├── huddle_scheduler.go ├── huddle_scheduler_test.go ├── huddle_search.go ├── huddle_search_test.go ├── huddle_storage_test.go └── huddle_test.go ├── membership.go ├── middleware ├── notification_handler.go └── notification_handler_test.go ├── mongo ├── care_team_service.go ├── membership_service.go ├── patient_service.go └── services.go ├── notifications ├── encounter_type_notification.go ├── notifications.go └── notifications_test.go ├── patient.go ├── services.go ├── subscription ├── notifier.go ├── notifier_test.go ├── resource_update_message.go ├── resource_watch.go └── resource_watch_test.go ├── testutil ├── mongo_suite.go └── web_suite.go ├── utilities └── code_loader.go ├── vendor ├── github.com │ ├── boj │ │ └── redistore │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ └── redistore.go │ ├── davecgh │ │ └── go-spew │ │ │ ├── LICENSE │ │ │ └── spew │ │ │ ├── bypass.go │ │ │ ├── bypasssafe.go │ │ │ ├── common.go │ │ │ ├── config.go │ │ │ ├── doc.go │ │ │ ├── dump.go │ │ │ ├── format.go │ │ │ └── spew.go │ ├── garyburd │ │ └── redigo │ │ │ ├── LICENSE │ │ │ ├── internal │ │ │ └── commandinfo.go │ │ │ └── redis │ │ │ ├── conn.go │ │ │ ├── doc.go │ │ │ ├── log.go │ │ │ ├── pool.go │ │ │ ├── pubsub.go │ │ │ ├── redis.go │ │ │ ├── reply.go │ │ │ ├── scan.go │ │ │ └── script.go │ ├── gin-gonic │ │ ├── contrib │ │ │ └── sessions │ │ │ │ ├── README.md │ │ │ │ ├── cookie.go │ │ │ │ ├── redis.go │ │ │ │ └── sessions.go │ │ └── gin │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── AUTHORS.md │ │ │ ├── BENCHMARKS.md │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── auth.go │ │ │ ├── binding │ │ │ ├── binding.go │ │ │ ├── default_validator.go │ │ │ ├── form.go │ │ │ ├── form_mapping.go │ │ │ ├── json.go │ │ │ ├── protobuf.go │ │ │ └── xml.go │ │ │ ├── context.go │ │ │ ├── debug.go │ │ │ ├── deprecated.go │ │ │ ├── errors.go │ │ │ ├── fs.go │ │ │ ├── gin.go │ │ │ ├── logger.go │ │ │ ├── logo.jpg │ │ │ ├── mode.go │ │ │ ├── path.go │ │ │ ├── recovery.go │ │ │ ├── render │ │ │ ├── data.go │ │ │ ├── html.go │ │ │ ├── json.go │ │ │ ├── redirect.go │ │ │ ├── render.go │ │ │ ├── text.go │ │ │ └── xml.go │ │ │ ├── response_writer.go │ │ │ ├── routergroup.go │ │ │ ├── test_helpers.go │ │ │ ├── tree.go │ │ │ ├── utils.go │ │ │ └── wercker.yml │ ├── golang │ │ └── protobuf │ │ │ ├── LICENSE │ │ │ └── proto │ │ │ ├── Makefile │ │ │ ├── clone.go │ │ │ ├── decode.go │ │ │ ├── encode.go │ │ │ ├── equal.go │ │ │ ├── extensions.go │ │ │ ├── lib.go │ │ │ ├── message_set.go │ │ │ ├── pointer_reflect.go │ │ │ ├── pointer_unsafe.go │ │ │ ├── properties.go │ │ │ ├── text.go │ │ │ └── text_parser.go │ ├── gorilla │ │ ├── context │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── context.go │ │ │ └── doc.go │ │ ├── securecookie │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── fuzz.go │ │ │ └── securecookie.go │ │ └── sessions │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── sessions.go │ │ │ └── store.go │ ├── icrowley │ │ └── fake │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── addresses.go │ │ │ ├── credit_cards.go │ │ │ ├── currencies.go │ │ │ ├── data.go │ │ │ ├── dates.go │ │ │ ├── fake.go │ │ │ ├── general.go │ │ │ ├── geo.go │ │ │ ├── internet.go │ │ │ ├── jobs.go │ │ │ ├── lorem_ipsum.go │ │ │ ├── names.go │ │ │ ├── personal.go │ │ │ └── products.go │ ├── intervention-engine │ │ └── fhir │ │ │ ├── LICENSE │ │ │ ├── auth │ │ │ ├── config.go │ │ │ ├── heart_auth.go │ │ │ ├── oauth.go │ │ │ └── oidc.go │ │ │ ├── models │ │ │ ├── account.go │ │ │ ├── address.go │ │ │ ├── allergyintolerance.go │ │ │ ├── annotation.go │ │ │ ├── appointment.go │ │ │ ├── appointmentresponse.go │ │ │ ├── attachment.go │ │ │ ├── auditevent.go │ │ │ ├── backboneelement.go │ │ │ ├── basic.go │ │ │ ├── binary.go │ │ │ ├── bodysite.go │ │ │ ├── bundle.go │ │ │ ├── careplan.go │ │ │ ├── claim.go │ │ │ ├── claimresponse.go │ │ │ ├── clinicalimpression.go │ │ │ ├── codeableconcept.go │ │ │ ├── codeableconcept_ext.go │ │ │ ├── coding.go │ │ │ ├── communication.go │ │ │ ├── communicationrequest.go │ │ │ ├── composition.go │ │ │ ├── conceptmap.go │ │ │ ├── condition.go │ │ │ ├── conformance.go │ │ │ ├── constructors.go │ │ │ ├── contactpoint.go │ │ │ ├── contract.go │ │ │ ├── coverage.go │ │ │ ├── dataelement.go │ │ │ ├── detectedissue.go │ │ │ ├── device.go │ │ │ ├── devicecomponent.go │ │ │ ├── devicemetric.go │ │ │ ├── deviceuserequest.go │ │ │ ├── deviceusestatement.go │ │ │ ├── diagnosticorder.go │ │ │ ├── diagnosticreport.go │ │ │ ├── documentmanifest.go │ │ │ ├── documentreference.go │ │ │ ├── domainresource.go │ │ │ ├── element.go │ │ │ ├── elementdefinition.go │ │ │ ├── eligibilityrequest.go │ │ │ ├── eligibilityresponse.go │ │ │ ├── encounter.go │ │ │ ├── enrollmentrequest.go │ │ │ ├── enrollmentresponse.go │ │ │ ├── episodeofcare.go │ │ │ ├── explanationofbenefit.go │ │ │ ├── extension.go │ │ │ ├── extension_ext.go │ │ │ ├── familymemberhistory.go │ │ │ ├── fhirdatetime.go │ │ │ ├── flag.go │ │ │ ├── goal.go │ │ │ ├── group.go │ │ │ ├── healthcareservice.go │ │ │ ├── humanname.go │ │ │ ├── identifier.go │ │ │ ├── imagingobjectselection.go │ │ │ ├── imagingstudy.go │ │ │ ├── immunization.go │ │ │ ├── immunizationrecommendation.go │ │ │ ├── implementationguide.go │ │ │ ├── list.go │ │ │ ├── location.go │ │ │ ├── media.go │ │ │ ├── medication.go │ │ │ ├── medicationadministration.go │ │ │ ├── medicationdispense.go │ │ │ ├── medicationorder.go │ │ │ ├── medicationstatement.go │ │ │ ├── messageheader.go │ │ │ ├── meta.go │ │ │ ├── namingsystem.go │ │ │ ├── narrative.go │ │ │ ├── nutritionorder.go │ │ │ ├── observation.go │ │ │ ├── operationdefinition.go │ │ │ ├── operationoutcome.go │ │ │ ├── operationoutcome_ext.go │ │ │ ├── order.go │ │ │ ├── orderresponse.go │ │ │ ├── organization.go │ │ │ ├── parameters.go │ │ │ ├── patient.go │ │ │ ├── paymentnotice.go │ │ │ ├── paymentreconciliation.go │ │ │ ├── period.go │ │ │ ├── person.go │ │ │ ├── practitioner.go │ │ │ ├── procedure.go │ │ │ ├── procedurerequest.go │ │ │ ├── processrequest.go │ │ │ ├── processresponse.go │ │ │ ├── provenance.go │ │ │ ├── quantity.go │ │ │ ├── questionnaire.go │ │ │ ├── questionnaireresponse.go │ │ │ ├── range.go │ │ │ ├── ratio.go │ │ │ ├── reference.go │ │ │ ├── reference_ext.go │ │ │ ├── referralrequest.go │ │ │ ├── relatedperson.go │ │ │ ├── resource.go │ │ │ ├── resource_helpers.go │ │ │ ├── riskassessment.go │ │ │ ├── sampleddata.go │ │ │ ├── schedule.go │ │ │ ├── searchparameter.go │ │ │ ├── signature.go │ │ │ ├── slot.go │ │ │ ├── specimen.go │ │ │ ├── structuredefinition.go │ │ │ ├── subscription.go │ │ │ ├── substance.go │ │ │ ├── supplydelivery.go │ │ │ ├── supplyrequest.go │ │ │ ├── testscript.go │ │ │ ├── timing.go │ │ │ ├── util.go │ │ │ ├── valueset.go │ │ │ └── visionprescription.go │ │ │ ├── search │ │ │ ├── mongo_registry.go │ │ │ ├── mongo_search.go │ │ │ ├── registry.go │ │ │ ├── search_param_types.go │ │ │ ├── search_parameter_dictionary.go │ │ │ └── url_query_parser.go │ │ │ └── server │ │ │ ├── batch_controller.go │ │ │ ├── bind.go │ │ │ ├── config.go │ │ │ ├── data_access.go │ │ │ ├── mongo_data_access.go │ │ │ ├── mongo_indexes.go │ │ │ ├── request_logger.go │ │ │ ├── resource_controller.go │ │ │ ├── routing.go │ │ │ └── server_setup.go │ ├── itsjamie │ │ └── gin-cors │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── cors.go │ ├── juju │ │ └── errors │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── error.go │ │ │ ├── errortypes.go │ │ │ ├── functions.go │ │ │ └── path.go │ ├── manucorporat │ │ └── sse │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── sse-decoder.go │ │ │ ├── sse-encoder.go │ │ │ └── writer.go │ ├── mitre │ │ └── heart │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── client.go │ │ │ ├── introspection.go │ │ │ ├── middleware.go │ │ │ ├── oidc.go │ │ │ └── routing.go │ ├── pmezard │ │ └── go-difflib │ │ │ ├── LICENSE │ │ │ └── difflib │ │ │ └── difflib.go │ ├── robfig │ │ └── cron │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── constantdelay.go │ │ │ ├── cron.go │ │ │ ├── doc.go │ │ │ ├── parser.go │ │ │ └── spec.go │ └── stretchr │ │ └── testify │ │ ├── LICENCE.txt │ │ ├── LICENSE │ │ ├── assert │ │ ├── assertion_forward.go │ │ ├── assertion_forward.go.tmpl │ │ ├── assertions.go │ │ ├── doc.go │ │ ├── errors.go │ │ ├── forward_assertions.go │ │ └── http_assertions.go │ │ ├── require │ │ ├── doc.go │ │ ├── forward_requirements.go │ │ ├── require.go │ │ ├── require.go.tmpl │ │ ├── require_forward.go │ │ ├── require_forward.go.tmpl │ │ └── requirements.go │ │ └── suite │ │ ├── doc.go │ │ ├── interfaces.go │ │ └── suite.go ├── golang.org │ └── x │ │ ├── net │ │ ├── LICENSE │ │ ├── PATENTS │ │ └── context │ │ │ └── context.go │ │ └── oauth2 │ │ ├── .travis.yml │ │ ├── AUTHORS │ │ ├── CONTRIBUTING.md │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── README.md │ │ ├── client_appengine.go │ │ ├── internal │ │ ├── oauth2.go │ │ ├── token.go │ │ └── transport.go │ │ ├── oauth2.go │ │ ├── token.go │ │ └── transport.go └── gopkg.in │ ├── go-playground │ └── validator.v8 │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── baked_in.go │ │ ├── cache.go │ │ ├── doc.go │ │ ├── logo.png │ │ ├── regexes.go │ │ ├── util.go │ │ └── validator.go │ ├── mgo.v2 │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── auth.go │ ├── bson │ │ ├── LICENSE │ │ ├── bson.go │ │ ├── decode.go │ │ └── encode.go │ ├── bulk.go │ ├── cluster.go │ ├── dbtest │ │ └── dbserver.go │ ├── doc.go │ ├── gridfs.go │ ├── internal │ │ ├── sasl │ │ │ ├── sasl.c │ │ │ ├── sasl.go │ │ │ ├── sasl_windows.c │ │ │ ├── sasl_windows.go │ │ │ ├── sasl_windows.h │ │ │ ├── sspi_windows.c │ │ │ └── sspi_windows.h │ │ └── scram │ │ │ └── scram.go │ ├── log.go │ ├── queue.go │ ├── raceoff.go │ ├── raceon.go │ ├── saslimpl.go │ ├── saslstub.go │ ├── server.go │ ├── session.go │ ├── socket.go │ └── stats.go │ ├── square │ └── go-jose.v1 │ │ ├── .gitcookies.sh.enc │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── BUG-BOUNTY.md │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── asymmetric.go │ │ ├── cipher │ │ ├── cbc_hmac.go │ │ ├── concat_kdf.go │ │ ├── ecdh_es.go │ │ └── key_wrap.go │ │ ├── crypter.go │ │ ├── doc.go │ │ ├── encoding.go │ │ ├── json │ │ ├── LICENSE │ │ ├── README.md │ │ ├── decode.go │ │ ├── encode.go │ │ ├── indent.go │ │ ├── scanner.go │ │ ├── stream.go │ │ └── tags.go │ │ ├── json_fork.go │ │ ├── json_std.go │ │ ├── jwe.go │ │ ├── jwk.go │ │ ├── jws.go │ │ ├── shared.go │ │ ├── signing.go │ │ ├── symmetric.go │ │ └── utils.go │ └── tomb.v2 │ ├── LICENSE │ ├── README.md │ └── tomb.go └── web ├── care_team_handlers.go ├── care_team_handlers_test.go ├── patient_handlers.go ├── patient_handlers_test.go ├── routes.go └── utils.go /.gitignore: -------------------------------------------------------------------------------- 1 | # Binary artifacts 2 | *ie 3 | 4 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 5 | *.o 6 | *.a 7 | *.so 8 | 9 | # Folders 10 | .vscode 11 | _obj 12 | _test 13 | 14 | # Architecture specific extensions/prefixes 15 | *.[568vq] 16 | [568vq].out 17 | 18 | *.cgo1.go 19 | *.cgo2.c 20 | _cgo_defun.c 21 | _cgo_gotypes.go 22 | _cgo_export.* 23 | 24 | _testmain.go 25 | 26 | *.exe 27 | *.test 28 | *.prof 29 | 30 | .DS_Store 31 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.7 5 | script: go test $(go list ./... | grep -v /vendor/) 6 | install: true 7 | services: 8 | - mongodb 9 | addons: 10 | apt: 11 | sources: 12 | - mongodb-3.2-precise 13 | packages: 14 | - mongodb-org-server 15 | branches: 16 | only: 17 | - master 18 | notifications: 19 | slack: 20 | secure: HSPbelGuRVi89pj8bvT2NgOvh5nBTNlXuMOhkHvKv6kOKpkGhc3t2bXk4m7lEJmpxZrhxaRjmhtEHQnfWt8hetA8MdFOyjSjNdOqtbnrugu6oR2SghyZ8WweaPbrycRuuuXVDj4oaBecIfw3GQLHZDBSAiXnuPfBu2D0Fq9Fh40= 21 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Start from a Debian image with the latest version of Go installed 2 | # and a workspace (GOPATH) configured at /go. 3 | FROM golang:1.7 4 | 5 | # Copy the local package files to the container's workspace. 6 | ADD . /go/src/github.com/intervention-engine/ie 7 | 8 | #Build the Intervention Engine server 9 | WORKDIR /go/src/github.com/intervention-engine/ie/cmd/ie 10 | RUN go build main.go 11 | 12 | # Document that the service listens on port 3001. 13 | EXPOSE 3001 14 | 15 | # Install Dockerize to get support for waiting on another container's port to be available. 16 | # This is needed here so docker-compose can be configured to wait on the mongodb port to be available. 17 | RUN apt-get update && apt-get install -y wget 18 | 19 | ENV DOCKERIZE_VERSION v0.4.0 20 | RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ 21 | && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ 22 | && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz 23 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /care_team.go: -------------------------------------------------------------------------------- 1 | package ie 2 | 3 | import "time" 4 | 5 | // CareTeam a collection of care providers providing care to a set of patients 6 | type CareTeam struct { 7 | ID string `bson:"_id,omitempty" json:"id,omitempty"` 8 | Name string `form:"name" bson:"name,omitempty" json:"name,omitempty" binding:"required"` 9 | Leader string `form:"leader" bson:"leader,omitempty" json:"leader,omitempty" binding:"required"` 10 | CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at,omitempty"` 11 | } 12 | 13 | // CareTeamService describes the interface for storing a CareTeam 14 | type CareTeamService interface { 15 | CareTeam(id string) (*CareTeam, error) 16 | CareTeams() ([]CareTeam, error) 17 | CreateCareTeam(c *CareTeam) error 18 | UpdateCareTeam(c *CareTeam) error 19 | DeleteCareTeam(id string) error 20 | } 21 | -------------------------------------------------------------------------------- /cmd/ie/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net" 6 | "os" 7 | 8 | "gopkg.in/mgo.v2" 9 | 10 | "github.com/intervention-engine/fhir/server" 11 | "github.com/intervention-engine/ie/mongo" 12 | "github.com/intervention-engine/ie/utilities" 13 | "github.com/intervention-engine/ie/web" 14 | ) 15 | 16 | func main() { 17 | args := getArgs() 18 | vars := getVars() 19 | if *args.CodeLookup { 20 | utilities.LoadICDFromCMS(vars.MongoURL, *args.Icd9URL, "ICD-9") 21 | utilities.LoadICDFromCMS(vars.MongoURL, *args.Icd10URL, "ICD-10") 22 | } 23 | 24 | var ip net.IP 25 | var selfURL string 26 | host, err := os.Hostname() 27 | if err != nil { 28 | log.Fatalln(err) 29 | } 30 | addrs, err := net.LookupIP(host) 31 | if err != nil { 32 | log.Println("Unable to lookup IP based on hostname, defaulting to localhost.") 33 | selfURL = "http://localhost:3001" 34 | } 35 | for _, addr := range addrs { 36 | if ipv4 := addr.To4(); ipv4 != nil { 37 | ip = ipv4 38 | selfURL = "http://" + ip.String() + ":3001" 39 | } 40 | } 41 | 42 | s := server.NewServer(vars.MongoURL) 43 | setupLogFile(s, vars.LogFilePath) 44 | 45 | ieSession, err := mgo.Dial(vars.MongoURL) 46 | if err != nil { 47 | log.Fatalln("dialing mongo failed for ie session at url: %s", vars.MongoURL) 48 | } 49 | defer ieSession.Close() 50 | 51 | services := &mongo.Services{S: ieSession} 52 | 53 | web.RegisterAPIRoutes(s.Engine, services) 54 | 55 | if *args.ReqLog { 56 | s.Engine.Use(server.RequestLoggerHandler) 57 | } 58 | 59 | huddleConfig := resolveHuddleConfig(args.HuddlePath, vars.HuddlePath) 60 | hc, cronJob := configureHuddles(huddleConfig) 61 | 62 | s.Engine.GET("/ScheduleHuddles", hc.ScheduleHandler) 63 | 64 | if len(huddleConfig) > 0 { 65 | cronJob.Start() 66 | defer cronJob.Stop() 67 | } 68 | 69 | closer := web.RegisterRoutes(s, selfURL, vars.RiskServiceURL, *args.SubFlag) 70 | defer closer() 71 | 72 | s.Run(server.DefaultConfig) 73 | } 74 | -------------------------------------------------------------------------------- /config/multifactor_huddle_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Interdisciplinary Huddle", 3 | "leaderID": "1", 4 | "days": [1], 5 | "lookAhead": 16, 6 | "riskConfig": { 7 | "riskMethod": {"system": "http://interventionengine.org/risk-assessments", "code": "MultiFactor"}, 8 | "frequencyConfigs": [ 9 | { 10 | "minScore": 4, 11 | "maxScore": 4, 12 | "idealFrequency": 1, 13 | "minFrequency": 1, 14 | "maxFrequency": 1 15 | }, { 16 | "minScore": 3, 17 | "maxScore": 3, 18 | "idealFrequency": 3, 19 | "minFrequency": 2, 20 | "maxFrequency": 4 21 | }, { 22 | "minScore": 2, 23 | "maxScore": 2, 24 | "idealFrequency": 6, 25 | "minFrequency": 4, 26 | "maxFrequency": 8 27 | }, { 28 | "minScore": 1, 29 | "maxScore": 1, 30 | "idealFrequency": 13, 31 | "minFrequency": 10, 32 | "maxFrequency": 16 33 | } 34 | ] 35 | }, 36 | "eventConfig": { 37 | "encounterConfigs": [ 38 | { 39 | "lookBackDays": 7, 40 | "typeCodes": [ 41 | { 42 | "name": "Hospital Discharge", 43 | "system": "http://snomed.info/sct", 44 | "code": "32485007", 45 | "useEndDate": true 46 | }, 47 | { 48 | "name": "Hospital Admission", 49 | "system": "http://snomed.info/sct", 50 | "code": "32485007" 51 | }, 52 | { 53 | "name": "Hospital Re-Admission Discharge", 54 | "system": "http://snomed.info/sct", 55 | "code": "417005", 56 | "useEndDate": true 57 | }, 58 | { 59 | "name": "Hospital Re-Admission", 60 | "system": "http://snomed.info/sct", 61 | "code": "417005" 62 | }, 63 | { 64 | "name": "Emergency Room Admission", 65 | "system": "http://snomed.info/sct", 66 | "code": "50849002" 67 | } 68 | ] 69 | } 70 | ] 71 | }, 72 | "rollOverDelayInDays": 3, 73 | "schedulerCronSpec": "0 0 0 * * *" 74 | } 75 | -------------------------------------------------------------------------------- /config/simple_huddle_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simple Huddle", 3 | "leaderID": "1", 4 | "days": [1], 5 | "lookAhead": 4, 6 | "riskConfig": { 7 | "riskMethod": {"system": "http://interventionengine.org/risk-assessments", "code": "Simple"}, 8 | "frequencyConfigs": [ 9 | { 10 | "minScore": 6, 11 | "maxScore": 10, 12 | "idealFrequency": 1, 13 | "minFrequency": 1, 14 | "maxFrequency": 1 15 | }, { 16 | "minScore": 4, 17 | "maxScore": 5, 18 | "idealFrequency": 2, 19 | "minFrequency": 1, 20 | "maxFrequency": 3 21 | }, { 22 | "minScore": 1, 23 | "maxScore": 3, 24 | "idealFrequency": 4, 25 | "minFrequency": 2, 26 | "maxFrequency": 6 27 | } 28 | ] 29 | }, 30 | "rollOverDelayInDays": 3, 31 | "schedulerCronSpec": "0 0 0 * * *" 32 | } 33 | -------------------------------------------------------------------------------- /controllers/code_lookup.go: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gin-gonic/gin" 7 | "github.com/intervention-engine/fhir/server" 8 | "github.com/intervention-engine/ie/utilities" 9 | "gopkg.in/mgo.v2/bson" 10 | ) 11 | 12 | type codeRequestForm struct { 13 | CodeSystem string `json:"codesystem"` 14 | Query string `json:"query"` 15 | ResultLimit int `json:"limit"` 16 | } 17 | 18 | func CodeLookup(c *gin.Context) { 19 | var f codeRequestForm 20 | 21 | if err := c.Bind(&f); err != nil { 22 | c.AbortWithError(http.StatusBadRequest, err) 23 | return 24 | } 25 | 26 | codecollection := server.Database.C("codelookup") 27 | 28 | result := []utilities.CodeEntry{} 29 | 30 | codeQuery := bson.M{ 31 | "codeSystem": f.CodeSystem, 32 | "$or": []interface{}{ 33 | bson.M{"code": bson.RegEx{Pattern: ".*" + f.Query + ".*", Options: "i"}}, 34 | bson.M{"name": bson.RegEx{Pattern: ".*" + f.Query + ".*", Options: "i"}}, 35 | }} 36 | 37 | pipeline := []bson.M{ 38 | {"$match": codeQuery}, 39 | {"$lookup": bson.M{ 40 | "from": "conditions", 41 | "localField": "code", 42 | "foreignField": "code.coding.code", 43 | "as": "_conditions", 44 | }}, 45 | {"$project": bson.M{ 46 | "_id": 1, 47 | "code": 1, 48 | "codeSystem": 1, 49 | "name": 1, 50 | "count": bson.M{ 51 | "$size": "$_conditions", 52 | }, 53 | }}, 54 | {"$sort": bson.D{ 55 | {"count", -1}, 56 | {"code", 1}, 57 | }}, 58 | {"$limit": f.ResultLimit}, 59 | } 60 | 61 | if err := codecollection.Pipe(pipeline).All(&result); err != nil { 62 | c.AbortWithError(http.StatusInternalServerError, err) 63 | return 64 | } 65 | 66 | c.Header("Access-Control-Allow-Origin", "*") 67 | c.JSON(http.StatusOK, result) 68 | } 69 | -------------------------------------------------------------------------------- /controllers/notification_count.go: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | 7 | "github.com/gin-gonic/gin" 8 | "github.com/intervention-engine/fhir/server" 9 | "gopkg.in/mgo.v2/bson" 10 | ) 11 | 12 | func NotificationCountHandler(c *gin.Context) { 13 | pipe := server.Database.C("communicationrequests").Pipe([]bson.M{{"$group": bson.M{"_id": "$subject.referenceid", "count": bson.M{"$sum": 1}}}}) 14 | var results []NotificationCountResult 15 | if err := pipe.All(&results); err != nil { 16 | log.Printf("Error getting notification count: %#v", err) 17 | c.AbortWithError(http.StatusInternalServerError, err) 18 | return 19 | } 20 | c.JSON(http.StatusOK, results) 21 | } 22 | 23 | type NotificationCountResult struct { 24 | Patient string `bson:"_id" json:"patient"` 25 | Count float64 `bson:"count" json:"count"` 26 | } 27 | -------------------------------------------------------------------------------- /controllers/pie.go: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | func GeneratePieHandler(riskEndpoint string) func(c *gin.Context) { 11 | f := func(c *gin.Context) { 12 | idString := c.Param("id") 13 | piesEndpoint := riskEndpoint + "/pies/" + idString 14 | resp, err := http.Get(piesEndpoint) 15 | 16 | if err != nil { 17 | c.AbortWithError(http.StatusInternalServerError, err) 18 | return 19 | } 20 | 21 | if _, err := io.Copy(c.Writer, resp.Body); err != nil { 22 | c.AbortWithError(http.StatusInternalServerError, err) 23 | return 24 | } 25 | c.Status(resp.StatusCode) 26 | c.Header("Content-Type", resp.Header.Get("Content-Type")) 27 | } 28 | return f 29 | } 30 | -------------------------------------------------------------------------------- /docs/MITRE_Intervention_Engine_Overview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intervention-engine/ie/543417b987f3862b6c197b5b12f6c3735856a67a/docs/MITRE_Intervention_Engine_Overview.pdf -------------------------------------------------------------------------------- /docs/docker-linux.md: -------------------------------------------------------------------------------- 1 | Building and Running the Intervention Engine Stack in a Containerized Environment with Docker (Ubuntu) 2 | ======================================================================================================== 3 | 4 | Docker support has moved to the [intervention-engine/ie-docker](https://github.com/intervention-engine/ie-docker) repo. Please see the [linux documentation](https://github.com/intervention-engine/ie-docker/blob/master/docs/docker-linux.md) in that repo. -------------------------------------------------------------------------------- /docs/docker-mac.md: -------------------------------------------------------------------------------- 1 | Building and Running the Intervention Engine Stack in a Containerized Environment with Docker (Mac OS X) 2 | ======================================================================================================== 3 | 4 | Docker support has moved to the [intervention-engine/ie-docker](https://github.com/intervention-engine/ie-docker) repo. Please see the [mac documentation](https://github.com/intervention-engine/ie-docker/blob/master/docs/docker-mac.md) in that repo. -------------------------------------------------------------------------------- /fixtures/age-group.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Group", 3 | "type": "person", 4 | "actual": false, 5 | "name": "People between 14 and 18", 6 | "characteristic": [ 7 | { 8 | "code": { 9 | "coding": [{"system": "http://loinc.org", "code": "21612-7"}], 10 | "text": "age" 11 | }, 12 | "valueRange": {"high": {"value": 18}, "low": {"value": 14}}, 13 | "exclude": false 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /fixtures/code-lookup.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"code":"001.0","codeSystem":"ICD-9","name":" Cholera due to vibrio cholerae"}, 3 | {"code":"001.1","codeSystem":"ICD-9","name":" Cholera due to vibrio cholerae el tor"}, 4 | {"code":"001.9","codeSystem":"ICD-9","name":" Cholera, unspecified"}, 5 | {"code":"002.0","codeSystem":"ICD-9","name":" Typhoid fever"}, 6 | {"code":"002.1","codeSystem":"ICD-9","name":" Paratyphoid fever A"}, 7 | {"code":"002.2","codeSystem":"ICD-9","name":" Paratyphoid fever B"}, 8 | {"code":"002.3","codeSystem":"ICD-9","name":" Paratyphoid fever C"}, 9 | {"code":"002.9","codeSystem":"ICD-9","name":" Paratyphoid fever, unspecified"}, 10 | {"code":"003.0","codeSystem":"ICD-9","name":" Salmonella gastroenteritis"}, 11 | {"code":"003.1","codeSystem":"ICD-9","name":" Salmonella septicemia"}, 12 | {"code":"003.20","codeSystem":"ICD-9","name":"Localized salmonella infection, unspecified"}, 13 | {"code":"003.21","codeSystem":"ICD-9","name":"Salmonella meningitis"}, 14 | {"code":"003.22","codeSystem":"ICD-9","name":"Salmonella pneumonia"}, 15 | {"code":"003.23","codeSystem":"ICD-9","name":"Salmonella arthritis"}, 16 | {"code":"003.24","codeSystem":"ICD-9","name":"Salmonella osteomyelitis"}, 17 | {"code":"003.29","codeSystem":"ICD-9","name":"Other localized salmonella infections"}, 18 | {"code":"003.8","codeSystem":"ICD-9","name":" Other specified salmonella infections"}, 19 | {"code":"003.9","codeSystem":"ICD-9","name":" Salmonella infection, unspecified"}, 20 | {"code":"004.0","codeSystem":"ICD-9","name":" Shigella dysenteriae"}, 21 | {"code":"004.1","codeSystem":"ICD-9","name":" Shigella flexneri"}, 22 | {"code":"004.2","codeSystem":"ICD-9","name":" Shigella boydii"}, 23 | {"code":"004.3","codeSystem":"ICD-9","name":" Shigella sonnei"}, 24 | {"code":"004.8","codeSystem":"ICD-9","name":" Other specified shigella infections"}, 25 | {"code":"004.9","codeSystem":"ICD-9","name":" Shigellosis, unspecified"}, 26 | {"code":"005.0","codeSystem":"ICD-9","name":" Staphylococcal food poisoning"}, 27 | {"code":"005.1","codeSystem":"ICD-9","name":" Botulism food poisoning"} 28 | ] 29 | -------------------------------------------------------------------------------- /fixtures/code_lookup_suppl.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "resourceType" : "Condition", 4 | "patient": { 5 | "reference": "Patient/1" 6 | }, 7 | "code" : { 8 | "coding" : [ 9 | {"system" : "http://hl7.org/fhir/sid/icd-9", "code" : "003.21"} 10 | ], 11 | "text" : "Salmonella meningitis" 12 | }, 13 | "onsetDateTime": "2015-04-01T00:00:00-04:00", 14 | "verificationStatus": "confirmed" 15 | }, 16 | { 17 | "resourceType" : "Condition", 18 | "patient": { 19 | "reference": "Patient/1" 20 | }, 21 | "code" : { 22 | "coding" : [ 23 | {"system" : "http://hl7.org/fhir/sid/icd-9", "code" : "003.22"} 24 | ], 25 | "text" : "Salmonella pneumonia" 26 | }, 27 | "onsetDateTime": "2015-04-01T00:00:00-04:00", 28 | "verificationStatus": "confirmed" 29 | }, 30 | { 31 | "resourceType" : "Condition", 32 | "patient": { 33 | "reference": "Patient/2" 34 | }, 35 | "code" : { 36 | "coding" : [ 37 | {"system" : "http://hl7.org/fhir/sid/icd-9", "code" : "003.21"} 38 | ], 39 | "text" : "Salmonella meningitis" 40 | }, 41 | "onsetDateTime": "2013-11-15T00:00:00-04:00", 42 | "verificationStatus": "confirmed" 43 | } 44 | ] -------------------------------------------------------------------------------- /fixtures/communication-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "CommunicationRequest", 3 | "category": { 4 | "coding": [{ 5 | "system": "http://snomed.info/sct", 6 | "code": "185087000" 7 | }] 8 | }, 9 | "payload": [{ 10 | "contentReference": { 11 | "reference": "http://localhost:3001/Encounter/5564865619d2504cba00006e", 12 | "type": "Encounter", 13 | "referenceid": "5564865619d2504cba00006e" 14 | } 15 | }], 16 | "status": "requested", 17 | "reason": [{ 18 | "coding": [{ 19 | "system": "http://snomed.info/sct", 20 | "code": "32485007", 21 | "display": "Hospital admission (procedure)" 22 | }] 23 | }], 24 | "orderedOn": "2015-05-26T10:42:30-04:00", 25 | "subject": { 26 | "reference": "http://MM198075-PC:3001/Patient/5564865619d2504cba00006c", 27 | "type": "Patient", 28 | "referenceid": "5564865619d2504cba00006c" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /fixtures/encounter-er-visit.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Encounter", 3 | "status": "finished", 4 | "type": [{ 5 | "coding": [{ 6 | "system": "http://www.ama-assn.org/go/cpt", 7 | "code": "99283" 8 | }] 9 | }], 10 | "patient": { 11 | "reference": "http://intervention-engine.org/Patient/5540f2041cd4623133000001" 12 | }, 13 | "period": { 14 | "start": "2015-04-01T05:15:00-04:00", 15 | "end": "2015-04-03T12:30:00-04:00" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fixtures/encounter-inpatient.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Encounter", 3 | "status": "finished", 4 | "type": [{ 5 | "coding": [{ 6 | "system": "http://snomed.info/sct", 7 | "code": "32485007", 8 | "display": "Hospital admission (procedure)" 9 | }] 10 | }], 11 | "patient": { 12 | "reference": "http://intervention-engine.org/Patient/5540f2041cd4623133000001" 13 | }, 14 | "period": { 15 | "start": "2015-04-01T05:15:00-04:00", 16 | "end": "2015-04-03T12:30:00-04:00" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /fixtures/encounter-office-visit.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Encounter", 3 | "status": "finished", 4 | "type": [{ 5 | "coding": [{ 6 | "system": "http://www.ama-assn.org/go/cpt", 7 | "code": "99201" 8 | }] 9 | }], 10 | "patient": { 11 | "reference": "http://intervention-engine.org/Patient/5540f2041cd4623133000001" 12 | }, 13 | "period": { 14 | "start": "2015-04-01T05:15:00-04:00", 15 | "end": "2015-04-03T12:30:00-04:00" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fixtures/encounter-planned.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Encounter", 3 | "status": "planned", 4 | "type": [{ 5 | "coding": [{ 6 | "system": "http://www.ama-assn.org/go/cpt", 7 | "code": "99201" 8 | }] 9 | }], 10 | "patient": { 11 | "reference": "http://intervention-engine.org/Patient/5540f2041cd4623133000001" 12 | }, 13 | "period": { 14 | "start": "2015-04-01T05:15:00-04:00", 15 | "end": "2015-04-03T12:30:00-04:00" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fixtures/encounter-readmission.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Encounter", 3 | "status": "finished", 4 | "type": [{ 5 | "coding": [{ 6 | "system": "http://snomed.info/sct", 7 | "code": "417005", 8 | "display": "Hospital re-admission (procedure)" 9 | }] 10 | }, { 11 | "coding": [{ 12 | "system": "http://snomed.info/sct", 13 | "code": "183452005", 14 | "display": "Emergency hospital admission (procedure)" 15 | }] 16 | }], 17 | "patient": { 18 | "reference": "http://intervention-engine.org/Patient/5540f2041cd4623133000001" 19 | }, 20 | "period": { 21 | "start": "2015-04-01T05:15:00-04:00", 22 | "end": "2015-04-03T12:30:00-04:00" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /fixtures/huddle_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simple Huddle", 3 | "leaderID": "1", 4 | "days": [1], 5 | "lookAhead": 4, 6 | "riskConfig": { 7 | "riskMethod": {"system": "http://interventionengine.org/risk-assessments", "code": "Simple"}, 8 | "frequencyConfigs": [ 9 | { 10 | "minScore": 6, 11 | "maxScore": 10, 12 | "idealFrequency": 1, 13 | "minFrequency": 1, 14 | "maxFrequency": 1 15 | }, { 16 | "minScore": 4, 17 | "maxScore": 5, 18 | "idealFrequency": 2, 19 | "minFrequency": 1, 20 | "maxFrequency": 3 21 | }, { 22 | "minScore": 1, 23 | "maxScore": 3, 24 | "idealFrequency": 4, 25 | "minFrequency": 2, 26 | "maxFrequency": 6 27 | } 28 | ] 29 | }, 30 | "eventConfig": { 31 | "encounterConfigs": [ 32 | { 33 | "lookBackDays": 7, 34 | "typeCodes": [ 35 | { 36 | "name": "Hospital Discharge", 37 | "system": "http://snomed.info/sct", 38 | "code": "32485007", 39 | "useEndDate": true 40 | }, 41 | { 42 | "name": "Hospital Admission", 43 | "system": "http://snomed.info/sct", 44 | "code": "32485007" 45 | }, 46 | { 47 | "name": "Hospital Re-Admission Discharge", 48 | "system": "http://snomed.info/sct", 49 | "code": "417005", 50 | "useEndDate": true 51 | }, 52 | { 53 | "name": "Hospital Re-Admission", 54 | "system": "http://snomed.info/sct", 55 | "code": "417005" 56 | }, 57 | { 58 | "name": "Emergency Room Admission", 59 | "system": "http://snomed.info/sct", 60 | "code": "50849002" 61 | } 62 | ] 63 | } 64 | ] 65 | }, 66 | "rollOverDelayInDays": 3, 67 | "schedulerCronSpec": "@midnight" 68 | } 69 | -------------------------------------------------------------------------------- /fixtures/huddle_config_bare.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Bare Huddle", 3 | "leaderID": "1", 4 | "days": [1], 5 | "lookAhead": 4, 6 | "schedulerCronSpec": "@midnight" 7 | } 8 | -------------------------------------------------------------------------------- /fixtures/medication-statement.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "MedicationStatement", 3 | "status": "completed", 4 | "patient" : { 5 | "reference" : "Patient/55c3847267803d2945000003" 6 | }, 7 | "effectivePeriod" : { 8 | "start" : "2015-04-01T00:00:00-04:00", 9 | "end" : "2015-04-03T12:30:00-04:00" 10 | }, 11 | "medicationCodeableConcept" : { 12 | "coding" : [ 13 | { 14 | "system" : "http://www.nlm.nih.gov/research/umls/rxnorm/", 15 | "code" : "1000048" 16 | } 17 | ], 18 | "text" : "Medication, Order: BH Antidepressant medication (Code List: 2.16.840.1.113883.3.1257.1.972)" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /fixtures/multi-code-group.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Group", 3 | "type": "person", 4 | "actual": false, 5 | "name": "Males with major depression", 6 | "characteristic": [ 7 | { 8 | "code": { 9 | "coding": [{"system": "http://loinc.org", "code": "21840-4"}], 10 | "text": "Gender" 11 | }, 12 | "valueCodeableConcept": { 13 | "coding": [{"system": "http://hl7.org/fhir/administrative-gender", "code": "male"}] 14 | }, 15 | "exclude": false 16 | }, 17 | { 18 | "code": { 19 | "coding": [{"system": "http://loinc.org", "code": "11450-4"}], 20 | "text": "Condition" 21 | }, 22 | "valueCodeableConcept": { 23 | "coding": [ 24 | { 25 | "system" : "http://hl7.org/fhir/sid/icd-9", 26 | "code" : "296.21" 27 | }, 28 | { 29 | "system" : "http://snomed.info/sct", 30 | "code" : "111513000" 31 | }] 32 | }, 33 | "exclude": false 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /fixtures/over-an-age-group.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Group", 3 | "type": "person", 4 | "actual": false, 5 | "name": "Males over age 10", 6 | "characteristic": [ 7 | { 8 | "code": { 9 | "coding": [{"system": "http://loinc.org", "code": "21612-7"}], 10 | "text": "age" 11 | }, 12 | "valueRange": {"low": {"value": 10}}, 13 | "exclude": false 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /fixtures/patients.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "576c9bcc8bd4d4bdc2ac42b5", 4 | "address": [{ 5 | "street": ["4691 7th Way"], 6 | "city": "Loyalton", 7 | "state": "WY", 8 | "postal_code": "01409" 9 | }], 10 | "age": 34, 11 | "gender": "female", 12 | "birthDate": "1982-07-21", 13 | "name": [{ 14 | "family": ["Banks9849"], 15 | "given": ["Jacqueline"] 16 | }], 17 | "next_huddle_id": "576c9bbf8bd4a4bdc2ac2038", 18 | "recent_risk_assessments": [ 19 | { 20 | "id": "576c9bcf8bd4d4bdc2ac481c", 21 | "risk_assessment_group_id": "576c9bcc8bd4d4bdc2ac429d", 22 | "date": "2016-01-01", 23 | "value": 3 24 | } 25 | ] 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /fixtures/risk-group.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Group", 3 | "type": "person", 4 | "actual": false, 5 | "name": "People with risk assessments", 6 | "characteristic": [ 7 | { 8 | "code": { 9 | "coding": [{"system": "http://loinc.org", "code": "30954-2"}], 10 | "text": "Observation" 11 | }, 12 | "valueCodeableConcept": { 13 | "coding": [{"system": "http://loinc.org", "code": "75492-9"}] 14 | }, 15 | "exclude": false 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /fixtures/sample-group-afib.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Group", 3 | "type": "person", 4 | "actual": false, 5 | "name": "Males with atrial fibrillation", 6 | "characteristic": [ 7 | { 8 | "code": { 9 | "coding": [{"system": "http://loinc.org", "code": "21840-4"}], 10 | "text": "Gender" 11 | }, 12 | "valueCodeableConcept": { 13 | "coding": [{"system": "http://hl7.org/fhir/administrative-gender", "code": "male"}] 14 | }, 15 | "exclude": false 16 | }, 17 | { 18 | "code": { 19 | "coding": [{"system": "http://loinc.org", "code": "11450-4"}], 20 | "text": "Condition" 21 | }, 22 | "valueCodeableConcept": { 23 | "coding": [{"system": "http://hl7.org/fhir/sid/icd-9", "code": "427.31"}] 24 | }, 25 | "exclude": false 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /fixtures/sample-group-or-codes.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Group", 3 | "type": "person", 4 | "actual": false, 5 | "name": "Males with major depression", 6 | "characteristic": [ 7 | { 8 | "code": { 9 | "coding": [{"system": "http://loinc.org", "code": "21840-4"}], 10 | "text": "Gender" 11 | }, 12 | "valueCodeableConcept": { 13 | "coding": [{"system": "http://hl7.org/fhir/administrative-gender", "code": "male"}] 14 | }, 15 | "exclude": false 16 | }, 17 | { 18 | "code": { 19 | "coding": [{"system": "http://loinc.org", "code": "11450-4"}], 20 | "text": "Condition" 21 | }, 22 | "valueCodeableConcept": { 23 | "coding": [ 24 | {"system": "http://foo", "code": "bar"}, 25 | {"system": "http://hl7.org/fhir/sid/icd-9", "code": "296.21"} 26 | ] 27 | }, 28 | "exclude": false 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /fixtures/sample-group.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Group", 3 | "type": "person", 4 | "actual": false, 5 | "name": "Males with major depression", 6 | "characteristic": [ 7 | { 8 | "code": { 9 | "coding": [{"system": "http://loinc.org", "code": "21840-4"}], 10 | "text": "Gender" 11 | }, 12 | "valueCodeableConcept": { 13 | "coding": [{"system": "http://hl7.org/fhir/administrative-gender", "code": "male"}] 14 | }, 15 | "exclude": false 16 | }, 17 | { 18 | "code": { 19 | "coding": [{"system": "http://loinc.org", "code": "11450-4"}], 20 | "text": "Condition" 21 | }, 22 | "valueCodeableConcept": { 23 | "coding": [{"system": "http://hl7.org/fhir/sid/icd-9", "code": "296.21"}] 24 | }, 25 | "exclude": false 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /fixtures/sample-lookup-request-by-code.json: -------------------------------------------------------------------------------- 1 | {"codesystem":"ICD-9", "query":"004", "limit":50} 2 | -------------------------------------------------------------------------------- /fixtures/sample-lookup-request-by-name.json: -------------------------------------------------------------------------------- 1 | {"codesystem":"ICD-9", "query":"salmone", "limit":50} 2 | -------------------------------------------------------------------------------- /fixtures/under-an-age-group.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType": "Group", 3 | "type": "person", 4 | "actual": false, 5 | "name": "Males under age 10", 6 | "characteristic": [ 7 | { 8 | "code": { 9 | "coding": [{"system": "http://loinc.org", "code": "21612-7"}], 10 | "text": "age" 11 | }, 12 | "valueRange": {"high": {"value": 10}} 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /groups/instacount.go: -------------------------------------------------------------------------------- 1 | package groups 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gin-gonic/gin" 7 | fhir "github.com/intervention-engine/fhir/models" 8 | "github.com/intervention-engine/fhir/search" 9 | "github.com/intervention-engine/fhir/server" 10 | ) 11 | 12 | func InstaCountAllHandler(c *gin.Context) { 13 | group := &fhir.Group{} 14 | if err := server.FHIRBind(c, group); err != nil { 15 | c.AbortWithError(http.StatusBadRequest, err) 16 | return 17 | } 18 | 19 | cInfo, err := LoadCharacteristicInfo(group.Characteristic) 20 | if err != nil { 21 | c.AbortWithError(http.StatusInternalServerError, err) 22 | return 23 | } 24 | 25 | // TODO: Get the searcher that is actually used in the FHIR server (requires registration refactoring) 26 | searcher := search.NewMongoSearcher(server.Database) 27 | patients, conditions, encounters, err := resolveGroupCounts(cInfo, searcher) 28 | if err != nil { 29 | c.AbortWithError(http.StatusInternalServerError, err) 30 | return 31 | } 32 | 33 | newResultMap := map[string]int{ 34 | "patients": patients, 35 | "conditions": conditions, 36 | "encounters": encounters, 37 | } 38 | 39 | c.JSON(http.StatusOK, newResultMap) 40 | } 41 | -------------------------------------------------------------------------------- /huddles/huddle_controller.go: -------------------------------------------------------------------------------- 1 | package huddles 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type HuddleSchedulerController struct { 10 | configs []HuddleConfig 11 | } 12 | 13 | func (h *HuddleSchedulerController) AddConfig(config *HuddleConfig) { 14 | h.configs = append(h.configs, *config) 15 | } 16 | 17 | func (h *HuddleSchedulerController) ScheduleHandler(c *gin.Context) { 18 | var scheduledHuddles []*Huddle 19 | for i := range h.configs { 20 | hs := NewHuddleScheduler(&h.configs[i]) 21 | huddles, err := hs.ScheduleHuddles() 22 | if err != nil { 23 | c.AbortWithError(http.StatusInternalServerError, err) 24 | return 25 | } 26 | scheduledHuddles = append(scheduledHuddles, huddles...) 27 | } 28 | c.JSON(http.StatusOK, scheduledHuddles) 29 | } 30 | -------------------------------------------------------------------------------- /huddles/huddle_search.go: -------------------------------------------------------------------------------- 1 | package huddles 2 | 3 | import "github.com/intervention-engine/fhir/search" 4 | 5 | // RegisterCustomSearchDefinitions registers the custom search definitions needed for the Huddle profile on Group 6 | func init() { 7 | registry := search.GlobalRegistry() 8 | registry.RegisterParameterInfo(search.SearchParamInfo{ 9 | Resource: "Group", 10 | Name: "activedatetime", 11 | Type: "date", 12 | Paths: []search.SearchParamPath{ 13 | {Path: "[]extension.activeDateTime", Type: "dateTime"}, 14 | }, 15 | }) 16 | registry.RegisterParameterInfo(search.SearchParamInfo{ 17 | Resource: "Group", 18 | Name: "leader", 19 | Type: "reference", 20 | Paths: []search.SearchParamPath{ 21 | {Path: "[]extension.leader", Type: "Reference"}, 22 | }, 23 | Targets: []string{ 24 | "Group", 25 | "Practitioner", 26 | "Organization", 27 | }, 28 | }) 29 | registry.RegisterParameterInfo(search.SearchParamInfo{ 30 | Resource: "Group", 31 | Name: "member-reviewed", 32 | Type: "date", 33 | Paths: []search.SearchParamPath{ 34 | {Path: "[]member.[]extension.reviewed", Type: "dateTime"}, 35 | }, 36 | }) 37 | } 38 | -------------------------------------------------------------------------------- /membership.go: -------------------------------------------------------------------------------- 1 | package ie 2 | 3 | import "time" 4 | 5 | // Membership Represents many to many relationship between patients and care teams 6 | type Membership struct { 7 | ID string `bson:"_id,omitempty" json:"id,omitempty"` 8 | CareTeamID string `bson:"care_team_id" json:"care_team_id" binding:"required"` 9 | PatientID string `bson:"care_team_id" json:"patient_id" binding:"required"` 10 | CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at,omitempty"` 11 | } 12 | 13 | // MembershipService Manage membership in care teams for patients 14 | type MembershipService interface { 15 | CreateMembership(mem Membership) error 16 | PatientMemberships(id string) ([]Membership, error) 17 | } 18 | -------------------------------------------------------------------------------- /middleware/notification_handler.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "net/url" 7 | "strings" 8 | 9 | "github.com/gin-gonic/gin" 10 | "github.com/intervention-engine/fhir/server" 11 | "github.com/intervention-engine/ie/notifications" 12 | ) 13 | 14 | type NotificationHandler struct { 15 | Registry *notifications.NotificationDefinitionRegistry 16 | } 17 | 18 | func (h *NotificationHandler) Handle() gin.HandlerFunc { 19 | return func(c *gin.Context) { 20 | c.Next() 21 | if c.IsAborted() { 22 | return 23 | } 24 | if c.Request.Method != "POST" { 25 | return 26 | } 27 | 28 | if resourceType, ok := c.Get("Resource"); ok { 29 | rs := resourceType.(string) 30 | resource, ok := c.Get(rs) 31 | if !ok { 32 | log.Printf("Error creating notification for resource type: %#v", resourceType) 33 | return 34 | } 35 | actionType, ok := c.Get("Action") 36 | if !ok { 37 | log.Printf("Error creating notification for resource: %#v", resource) 38 | return 39 | } 40 | 41 | var reg *notifications.NotificationDefinitionRegistry 42 | if h.Registry != nil { 43 | reg = h.Registry 44 | } else { 45 | reg = notifications.DefaultNotificationDefinitionRegistry 46 | } 47 | for _, def := range reg.GetAll() { 48 | if def.Triggers(resource, actionType.(string)) { 49 | notification := def.GetNotification(resource, actionType.(string), h.getBaseURL(c.Request)) 50 | if err := server.Database.C("communicationrequests").Insert(notification); err != nil { 51 | log.Printf("Error creating notification.\n\tNotification: %#v\n\tResource: %#v\n\tError: %#v", notification, resource, err) 52 | return 53 | } 54 | } 55 | } 56 | } 57 | } 58 | } 59 | 60 | func (h *NotificationHandler) getBaseURL(r *http.Request) string { 61 | newURL := url.URL(*r.URL) 62 | if newURL.Host == "" { 63 | newURL.Host = r.Host 64 | } 65 | if newURL.Scheme == "" { 66 | if strings.HasSuffix(newURL.Host, ":443") { 67 | newURL.Scheme = "https" 68 | } else { 69 | newURL.Scheme = "http" 70 | } 71 | } 72 | newURL.Path = "" 73 | 74 | return newURL.String() 75 | } 76 | -------------------------------------------------------------------------------- /mongo/care_team_service.go: -------------------------------------------------------------------------------- 1 | package mongo 2 | 3 | import ( 4 | "errors" 5 | "strings" 6 | "time" 7 | 8 | "github.com/intervention-engine/ie" 9 | mgo "gopkg.in/mgo.v2" 10 | "gopkg.in/mgo.v2/bson" 11 | ) 12 | 13 | type CareTeamService struct { 14 | C *mgo.Collection 15 | } 16 | 17 | func (s *CareTeamService) CareTeam(id string) (*ie.CareTeam, error) { 18 | if !bson.IsObjectIdHex(id) { 19 | return nil, errors.New("bad id") 20 | } 21 | var c ie.CareTeam 22 | err := s.C.FindId(id).One(&c) 23 | if err != nil { 24 | return nil, err 25 | } 26 | return &c, nil 27 | } 28 | 29 | func (s *CareTeamService) CareTeams() ([]ie.CareTeam, error) { 30 | var cc []ie.CareTeam 31 | err := s.C.Find(nil).All(&cc) 32 | if err != nil { 33 | return nil, err 34 | } 35 | return cc, nil 36 | } 37 | 38 | func (s *CareTeamService) CreateCareTeam(c *ie.CareTeam) error { 39 | c.ID = compensateForBsonFail(bson.NewObjectId().String()) 40 | c.CreatedAt = time.Now() 41 | err := s.C.Insert(c) 42 | return err 43 | } 44 | 45 | func (s *CareTeamService) UpdateCareTeam(c *ie.CareTeam) error { 46 | if !bson.IsObjectIdHex(c.ID) { 47 | return errors.New("bad id") 48 | } 49 | err := s.C.UpdateId(c.ID, c) 50 | return err 51 | } 52 | 53 | func (s *CareTeamService) DeleteCareTeam(id string) error { 54 | if !bson.IsObjectIdHex(id) { 55 | return errors.New("bad id") 56 | } 57 | err := s.C.RemoveId(id) 58 | return err 59 | } 60 | 61 | func compensateForBsonFail(id string) string { 62 | result := strings.Split(id, "\"") 63 | if len(result) != 3 { 64 | return "" 65 | } 66 | return result[1] 67 | } 68 | -------------------------------------------------------------------------------- /mongo/membership_service.go: -------------------------------------------------------------------------------- 1 | package mongo 2 | 3 | import ( 4 | "github.com/intervention-engine/ie" 5 | mgo "gopkg.in/mgo.v2" 6 | "gopkg.in/mgo.v2/bson" 7 | ) 8 | 9 | // MembershipService mongodb membership service 10 | type MembershipService struct { 11 | C *mgo.Collection 12 | } 13 | 14 | // CreateMembership create membership in mongodb 15 | func (m *MembershipService) CreateMembership(mem ie.Membership) error { 16 | return m.C.Insert(mem) 17 | } 18 | 19 | // PatientMemberships list of memberships for a given care team 20 | func (m *MembershipService) PatientMemberships(id string) ([]ie.Membership, error) { 21 | var mems []ie.Membership 22 | err := m.C.Find(bson.M{"care_team_id": id}).All(&mems) 23 | return mems, err 24 | } 25 | -------------------------------------------------------------------------------- /mongo/services.go: -------------------------------------------------------------------------------- 1 | package mongo 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/gin-gonic/gin" 7 | "github.com/intervention-engine/ie" 8 | mgo "gopkg.in/mgo.v2" 9 | ) 10 | 11 | const dbName = "fhir" 12 | 13 | type Services struct { 14 | S *mgo.Session 15 | } 16 | 17 | // NewMongoService creates new Mongo service from MongodB URL and returns 18 | // service and func used to clean up connection 19 | func NewMongoService(url string) (Services, func()) { 20 | s, err := mgo.Dial(url) 21 | srv := Services{S: s} 22 | if err != nil { 23 | log.Fatalln("dialing mongo failed for ie session at url: %s", url) 24 | } 25 | 26 | return srv, srv.S.Close 27 | } 28 | 29 | // CareTeamService puts a mgo.Collection named "care_teams" into the context for the actual handler to use. 30 | func (s *Services) CareTeamService() ie.Adapter { 31 | return func(h gin.HandlerFunc) gin.HandlerFunc { 32 | return func(ctx *gin.Context) { 33 | session := s.S.Copy() 34 | defer session.Close() 35 | c := col(session, "care_teams") 36 | service := &CareTeamService{C: c} 37 | ctx.Set("careTeamService", service) 38 | h(ctx) 39 | } 40 | } 41 | } 42 | 43 | func (s *Services) PatientService() ie.Adapter { 44 | return func(h gin.HandlerFunc) gin.HandlerFunc { 45 | return func(ctx *gin.Context) { 46 | session := s.S.Copy() 47 | defer session.Close() 48 | col := col(session, "patients") 49 | service := &PatientService{C: col} 50 | ctx.Set("patientService", service) 51 | h(ctx) 52 | } 53 | } 54 | } 55 | 56 | func (s *Services) MembershipService() ie.Adapter { 57 | return func(h gin.HandlerFunc) gin.HandlerFunc { 58 | return func(ctx *gin.Context) { 59 | session := s.S.Copy() 60 | defer session.Close() 61 | col := col(session, "care_team_memberships") 62 | service := &MembershipService{C: col} 63 | ctx.Set("membershipService", service) 64 | } 65 | } 66 | } 67 | 68 | func col(sess *mgo.Session, col string) *mgo.Collection { 69 | return sess.DB(dbName).C(col) 70 | } 71 | -------------------------------------------------------------------------------- /notifications/notifications.go: -------------------------------------------------------------------------------- 1 | package notifications 2 | 3 | import "github.com/intervention-engine/fhir/models" 4 | 5 | /* The NotificationDefinition interface should be implemented by all notification definitions */ 6 | type NotificationDefinition interface { 7 | Name() string 8 | Triggers(resource interface{}, action string) bool 9 | GetNotification(resource interface{}, action string, baseURL string) *models.CommunicationRequest 10 | } 11 | 12 | // Setup the registry that keeps track of all the notification definitions 13 | 14 | type NotificationDefinitionRegistry struct { 15 | defs []NotificationDefinition 16 | } 17 | 18 | func (r *NotificationDefinitionRegistry) Register(def NotificationDefinition) { 19 | r.defs = append(r.defs, def) 20 | } 21 | 22 | func (r *NotificationDefinitionRegistry) RegisterAll(slice []NotificationDefinition) { 23 | r.defs = append(r.defs, slice...) 24 | } 25 | 26 | func (r *NotificationDefinitionRegistry) GetAll() []NotificationDefinition { 27 | return r.defs 28 | } 29 | 30 | var DefaultNotificationDefinitionRegistry = new(NotificationDefinitionRegistry) 31 | -------------------------------------------------------------------------------- /patient.go: -------------------------------------------------------------------------------- 1 | package ie 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/intervention-engine/fhir/models" 7 | ) 8 | 9 | type PatientService interface { 10 | Patient(id string) (*Patient, error) 11 | Patients() ([]Patient, error) 12 | PatientsByID(ids []string) ([]Patient, error) 13 | } 14 | 15 | type Patient struct { 16 | ID string `json:"id"` 17 | Address Address `json:"address"` 18 | Age int `json:"age"` 19 | Gender string `json:"gender"` 20 | BirthDate *models.FHIRDateTime `json:"birthDate"` 21 | Name Name `json:"name"` 22 | NextHuddleID string `json:"nextHuddleId"` 23 | RecentRiskAssessments []RiskAssessment `json:"recentRiskAssessments"` 24 | } 25 | 26 | type Address struct { 27 | Street []string `json:"street"` 28 | City string `json:"city"` 29 | State string `json:"state"` 30 | PostalCode string `json:"postalCode"` 31 | } 32 | 33 | type Name struct { 34 | Family string `json:"family"` 35 | Given string `json:"given"` 36 | MiddleInitial string `json:"middleInitial"` 37 | Full string `json:"full"` 38 | } 39 | 40 | type RiskAssessment struct { 41 | ID string `json:"id"` 42 | GroupID string `json:"riskAssessmentGroupId"` 43 | Date time.Time `json:"date"` 44 | Value int `json:"value"` 45 | } 46 | -------------------------------------------------------------------------------- /services.go: -------------------------------------------------------------------------------- 1 | package ie 2 | 3 | import "github.com/gin-gonic/gin" 4 | 5 | type Adapter func(gin.HandlerFunc) gin.HandlerFunc 6 | 7 | func Adapt(h gin.HandlerFunc, adapters ...Adapter) gin.HandlerFunc { 8 | for _, wrapper := range adapters { 9 | h = wrapper(h) 10 | } 11 | return h 12 | } 13 | 14 | // Services Interface for services to be shared with the web handlers 15 | type Services interface { 16 | CareTeamService() Adapter 17 | PatientService() Adapter 18 | MembershipService() Adapter 19 | } 20 | -------------------------------------------------------------------------------- /subscription/notifier.go: -------------------------------------------------------------------------------- 1 | package subscription 2 | 3 | import ( 4 | "net/http" 5 | "net/url" 6 | "sync" 7 | 8 | "github.com/intervention-engine/fhir/models" 9 | "github.com/intervention-engine/fhir/server" 10 | "gopkg.in/mgo.v2/bson" 11 | ) 12 | 13 | func NotifySubscribers(subUpdateQueue <-chan ResourceUpdateMessage, rootURL string, wg *sync.WaitGroup) { 14 | for { 15 | rum, ok := <-subUpdateQueue 16 | if !ok { 17 | wg.Done() 18 | return 19 | } 20 | subsCollection := server.Database.C("subscriptions") 21 | query := subsCollection.Find(bson.M{"channel.type": "rest-hook"}) 22 | var subscriptions []models.Subscription 23 | query.All(&subscriptions) 24 | for _, s := range subscriptions { 25 | resp, err := http.PostForm(s.Channel.Endpoint, 26 | url.Values{"patientId": {rum.PatientID}, 27 | "timestamp": {rum.Timestamp}, 28 | "fhirEndpointUrl": {rootURL}}) 29 | if err != nil { 30 | s.Error = err.Error() 31 | subsCollection.Update(bson.M{"_id": s.Id}, s) 32 | } else { 33 | resp.Body.Close() 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /subscription/resource_update_message.go: -------------------------------------------------------------------------------- 1 | package subscription 2 | 3 | type ResourceUpdateMessage struct { 4 | PatientID string 5 | Timestamp string 6 | } 7 | 8 | func NewResourceUpdateMessage(patientID, timestamp string) ResourceUpdateMessage { 9 | return ResourceUpdateMessage{PatientID: patientID, Timestamp: timestamp} 10 | } 11 | -------------------------------------------------------------------------------- /subscription/resource_watch.go: -------------------------------------------------------------------------------- 1 | package subscription 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/gin-gonic/gin" 7 | fhirmodels "github.com/intervention-engine/fhir/models" 8 | ) 9 | 10 | func GenerateResourceWatch(subUpdateQueue chan<- ResourceUpdateMessage) gin.HandlerFunc { 11 | return func(c *gin.Context) { 12 | c.Next() 13 | if c.IsAborted() { 14 | return 15 | } 16 | if c.Request.Method == "GET" { 17 | return 18 | } 19 | if resourceType, ok := c.Get("Resource"); ok { 20 | if resource, ok := c.Get(resourceType.(string)); ok { 21 | HandleResourceUpdate(subUpdateQueue, resource) 22 | } 23 | } 24 | return 25 | } 26 | } 27 | 28 | func HandleResourceUpdate(subUpdateQueue chan<- ResourceUpdateMessage, resource interface{}) { 29 | for patientID, timestamp := range triggeredPatients(resource) { 30 | ru := NewResourceUpdateMessage(patientID, timestamp.Format(time.RFC3339)) 31 | subUpdateQueue <- ru 32 | } 33 | } 34 | 35 | func triggeredPatients(resource interface{}) map[string]time.Time { 36 | result := make(map[string]time.Time) 37 | 38 | // TODO: This code causes panics when the expected time fields are not present! 39 | // Need to determine correct course of action when that occurs. 40 | switch t := resource.(type) { 41 | case *fhirmodels.Condition: 42 | result[t.Patient.ReferencedID] = t.OnsetDateTime.Time 43 | case *fhirmodels.MedicationStatement: 44 | result[t.Patient.ReferencedID] = t.EffectivePeriod.Start.Time 45 | case *fhirmodels.Encounter: 46 | result[t.Patient.ReferencedID] = t.Period.Start.Time 47 | case *fhirmodels.Bundle: 48 | for _, entry := range t.Entry { 49 | if entry.Resource != nil { 50 | subResult := triggeredPatients(entry.Resource) 51 | for k, v := range subResult { 52 | if t, ok := result[k]; !ok || v.After(t) { 53 | result[k] = v 54 | } 55 | } 56 | 57 | } 58 | } 59 | } 60 | return result 61 | } 62 | -------------------------------------------------------------------------------- /testutil/web_suite.go: -------------------------------------------------------------------------------- 1 | package testutil 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | "net/http/httptest" 7 | 8 | "github.com/gin-gonic/gin" 9 | "github.com/stretchr/testify/suite" 10 | ) 11 | 12 | // WebSuite Base Suite for web Handlers 13 | type WebSuite struct { 14 | suite.Suite 15 | E *gin.Engine 16 | } 17 | 18 | // LoadGin initialize gin API 19 | func (suite *WebSuite) LoadGin() *gin.RouterGroup { 20 | gin.SetMode(gin.TestMode) 21 | suite.E = gin.Default() 22 | return suite.E.Group("/api") 23 | } 24 | 25 | // AssertGetRequest Create a GET request and returns a response recorder for testing 26 | func (suite *WebSuite) AssertGetRequest(path string, httpCode int) *httptest.ResponseRecorder { 27 | return suite.assertRequest(http.MethodGet, path, nil, httpCode) 28 | } 29 | 30 | // AssertPostRequest Create a POST request and returns a reponse recorder for testing 31 | func (suite *WebSuite) AssertPostRequest(path string, body io.Reader, httpCode int) *httptest.ResponseRecorder { 32 | return suite.assertRequest(http.MethodPost, path, body, httpCode) 33 | } 34 | 35 | // AssertPuttRequest Create a PUT request and returns a reponse recorder for testing 36 | func (suite *WebSuite) AssertPutRequest(path string, body io.Reader, httpCode int) *httptest.ResponseRecorder { 37 | return suite.assertRequest(http.MethodPut, path, body, httpCode) 38 | } 39 | 40 | func (suite *WebSuite) assertRequest(method string, path string, body io.Reader, httpCode int) *httptest.ResponseRecorder { 41 | req, err := http.NewRequest(method, path, body) 42 | if err != nil { 43 | suite.T().Errorf("failed to make request: %#+v\n", err) 44 | } 45 | w := httptest.NewRecorder() 46 | suite.E.ServeHTTP(w, req) 47 | suite.T().Logf("body: %v\n", w.Body.String()) 48 | suite.Assert().Equal(httpCode, w.Code) 49 | 50 | return w 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/boj/redistore/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | -------------------------------------------------------------------------------- /vendor/github.com/boj/redistore/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Brian Jones 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/boj/redistore/README.md: -------------------------------------------------------------------------------- 1 | # redistore 2 | 3 | [![Build Status](https://drone.io/github.com/boj/redistore/status.png)](https://drone.io/github.com/boj/redistore/latest) 4 | 5 | A session store backend for [gorilla/sessions](http://www.gorillatoolkit.org/pkg/sessions) - [src](https://github.com/gorilla/sessions). 6 | 7 | ## Requirements 8 | 9 | Depends on the [Redigo](https://github.com/garyburd/redigo) Redis library. 10 | 11 | ## Installation 12 | 13 | go get gopkg.in/boj/redistore.v1 14 | 15 | ## Documentation 16 | 17 | Available on [godoc.org](http://www.godoc.org/gopkg.in/boj/redistore.v1). 18 | 19 | See http://www.gorillatoolkit.org/pkg/sessions for full documentation on underlying interface. 20 | 21 | ### Example 22 | 23 | // Fetch new store. 24 | store, err := NewRediStore(10, "tcp", ":6379", "", []byte("secret-key")) 25 | if err != nil { 26 | panic(err) 27 | } 28 | defer store.Close() 29 | 30 | // Get a session. 31 | session, err = store.Get(req, "session-key") 32 | if err != nil { 33 | log.Error(err.Error()) 34 | } 35 | 36 | // Add a value. 37 | session.Values["foo"] = "bar" 38 | 39 | // Save. 40 | if err = sessions.Save(req, rsp); err != nil { 41 | t.Fatalf("Error saving session: %v", err) 42 | } 43 | 44 | // Delete session. 45 | session.Options.MaxAge = -1 46 | if err = sessions.Save(req, rsp); err != nil { 47 | t.Fatalf("Error saving session: %v", err) 48 | } 49 | 50 | // Change session storage configuration for MaxAge = 10 days. 51 | store.SetMaxAge(10*24*3600) 52 | 53 | -------------------------------------------------------------------------------- /vendor/github.com/boj/redistore/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package redistore is a session store backend for gorilla/sessions 3 | */ 4 | package redistore 5 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2013 Dave Collins 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when either the code is running on Google App Engine or "-tags disableunsafe" 17 | // is added to the go build command line. 18 | // +build appengine disableunsafe 19 | 20 | package spew 21 | 22 | import "reflect" 23 | 24 | const ( 25 | // UnsafeDisabled is a build-time constant which specifies whether or 26 | // not access to the unsafe package is available. 27 | UnsafeDisabled = true 28 | ) 29 | 30 | // unsafeReflectValue typically converts the passed reflect.Value into a one 31 | // that bypasses the typical safety restrictions preventing access to 32 | // unaddressable and unexported data. However, doing this relies on access to 33 | // the unsafe package. This is a stub version which simply returns the passed 34 | // reflect.Value when the unsafe package is not available. 35 | func unsafeReflectValue(v reflect.Value) reflect.Value { 36 | return v 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/garyburd/redigo/internal/commandinfo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Gary Burd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "strings" 19 | ) 20 | 21 | const ( 22 | WatchState = 1 << iota 23 | MultiState 24 | SubscribeState 25 | MonitorState 26 | ) 27 | 28 | type CommandInfo struct { 29 | Set, Clear int 30 | } 31 | 32 | var commandInfos = map[string]CommandInfo{ 33 | "WATCH": {Set: WatchState}, 34 | "UNWATCH": {Clear: WatchState}, 35 | "MULTI": {Set: MultiState}, 36 | "EXEC": {Clear: WatchState | MultiState}, 37 | "DISCARD": {Clear: WatchState | MultiState}, 38 | "PSUBSCRIBE": {Set: SubscribeState}, 39 | "SUBSCRIBE": {Set: SubscribeState}, 40 | "MONITOR": {Set: MonitorState}, 41 | } 42 | 43 | func init() { 44 | for n, ci := range commandInfos { 45 | commandInfos[strings.ToLower(n)] = ci 46 | } 47 | } 48 | 49 | func LookupCommandInfo(commandName string) CommandInfo { 50 | if ci, ok := commandInfos[commandName]; ok { 51 | return ci 52 | } 53 | return commandInfos[strings.ToUpper(commandName)] 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/garyburd/redigo/redis/redis.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Gary Burd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package redis 16 | 17 | // Error represents an error returned in a command reply. 18 | type Error string 19 | 20 | func (err Error) Error() string { return string(err) } 21 | 22 | // Conn represents a connection to a Redis server. 23 | type Conn interface { 24 | // Close closes the connection. 25 | Close() error 26 | 27 | // Err returns a non-nil value if the connection is broken. The returned 28 | // value is either the first non-nil value returned from the underlying 29 | // network connection or a protocol parsing error. Applications should 30 | // close broken connections. 31 | Err() error 32 | 33 | // Do sends a command to the server and returns the received reply. 34 | Do(commandName string, args ...interface{}) (reply interface{}, err error) 35 | 36 | // Send writes the command to the client's output buffer. 37 | Send(commandName string, args ...interface{}) error 38 | 39 | // Flush flushes the output buffer to the Redis server. 40 | Flush() error 41 | 42 | // Receive receives a single reply from the Redis server 43 | Receive() (reply interface{}, err error) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/contrib/sessions/README.md: -------------------------------------------------------------------------------- 1 | # sessions 2 | Gin middleware for session management with multi-backend support (currently cookie, Redis). 3 | 4 | ## Examples 5 | 6 | #### cookie-based 7 | 8 | ```go 9 | package main 10 | 11 | import ( 12 | "github.com/gin-gonic/contrib/sessions" 13 | "github.com/gin-gonic/gin" 14 | ) 15 | 16 | func main() { 17 | r := gin.Default() 18 | store := sessions.NewCookieStore([]byte("secret")) 19 | r.Use(sessions.Sessions("mysession", store)) 20 | 21 | r.GET("/incr", func(c *gin.Context) { 22 | session := sessions.Default(c) 23 | var count int 24 | v := session.Get("count") 25 | if v == nil { 26 | count = 0 27 | } else { 28 | count = v.(int) 29 | count += 1 30 | } 31 | session.Set("count", count) 32 | session.Save() 33 | c.JSON(200, gin.H{"count": count}) 34 | }) 35 | r.Run(":8000") 36 | } 37 | ``` 38 | 39 | #### Redis 40 | 41 | ```go 42 | package main 43 | 44 | import ( 45 | "github.com/gin-gonic/contrib/sessions" 46 | "github.com/gin-gonic/gin" 47 | ) 48 | 49 | func main() { 50 | r := gin.Default() 51 | store, _ := sessions.NewRedisStore(10, "tcp", "localhost:6379", "", []byte("secret")) 52 | r.Use(sessions.Sessions("session", store)) 53 | 54 | r.GET("/incr", func(c *gin.Context) { 55 | session := sessions.Default(c) 56 | var count int 57 | v := session.Get("count") 58 | if v == nil { 59 | count = 0 60 | } else { 61 | count = v.(int) 62 | count += 1 63 | } 64 | session.Set("count", count) 65 | session.Save() 66 | c.JSON(200, gin.H{"count": count}) 67 | }) 68 | r.Run(":8000") 69 | } 70 | ``` -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/contrib/sessions/cookie.go: -------------------------------------------------------------------------------- 1 | package sessions 2 | 3 | import ( 4 | "github.com/gorilla/sessions" 5 | ) 6 | 7 | type CookieStore interface { 8 | Store 9 | } 10 | 11 | // Keys are defined in pairs to allow key rotation, but the common case is to set a single 12 | // authentication key and optionally an encryption key. 13 | // 14 | // The first key in a pair is used for authentication and the second for encryption. The 15 | // encryption key can be set to nil or omitted in the last pair, but the authentication key 16 | // is required in all pairs. 17 | // 18 | // It is recommended to use an authentication key with 32 or 64 bytes. The encryption key, 19 | // if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes. 20 | func NewCookieStore(keyPairs ...[]byte) CookieStore { 21 | return &cookieStore{sessions.NewCookieStore(keyPairs...)} 22 | } 23 | 24 | type cookieStore struct { 25 | *sessions.CookieStore 26 | } 27 | 28 | func (c *cookieStore) Options(options Options) { 29 | c.CookieStore.Options = &sessions.Options{ 30 | Path: options.Path, 31 | Domain: options.Domain, 32 | MaxAge: options.MaxAge, 33 | Secure: options.Secure, 34 | HttpOnly: options.HttpOnly, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/contrib/sessions/redis.go: -------------------------------------------------------------------------------- 1 | package sessions 2 | 3 | import ( 4 | "github.com/boj/redistore" 5 | "github.com/gorilla/sessions" 6 | ) 7 | 8 | type RedisStore interface { 9 | Store 10 | } 11 | 12 | // size: maximum number of idle connections. 13 | // network: tcp or udp 14 | // address: host:port 15 | // password: redis-password 16 | // Keys are defined in pairs to allow key rotation, but the common case is to set a single 17 | // authentication key and optionally an encryption key. 18 | // 19 | // The first key in a pair is used for authentication and the second for encryption. The 20 | // encryption key can be set to nil or omitted in the last pair, but the authentication key 21 | // is required in all pairs. 22 | // 23 | // It is recommended to use an authentication key with 32 or 64 bytes. The encryption key, 24 | // if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes. 25 | func NewRedisStore(size int, network, address, password string, keyPairs ...[]byte) (RedisStore, error) { 26 | store, err := redistore.NewRediStore(size, network, address, password, keyPairs...) 27 | if err != nil { 28 | return nil, err 29 | } 30 | return &redisStore{store}, nil 31 | } 32 | 33 | type redisStore struct { 34 | *redistore.RediStore 35 | } 36 | 37 | func (c *redisStore) Options(options Options) { 38 | c.RediStore.Options = &sessions.Options{ 39 | Path: options.Path, 40 | Domain: options.Domain, 41 | MaxAge: options.MaxAge, 42 | Secure: options.Secure, 43 | HttpOnly: options.HttpOnly, 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/.gitignore: -------------------------------------------------------------------------------- 1 | Godeps/* 2 | !Godeps/Godeps.json 3 | coverage.out 4 | count.out 5 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.4 5 | - 1.5 6 | - 1.6 7 | - tip 8 | 9 | script: 10 | - go get golang.org/x/tools/cmd/cover 11 | - go get github.com/mattn/goveralls 12 | - go test -v -covermode=count -coverprofile=coverage.out 13 | 14 | after_success: 15 | - goveralls -coverprofile=coverage.out -service=travis-ci -repotoken yFj7FrCeddvBzUaaCyG33jCLfWXeb93eA 16 | 17 | notifications: 18 | webhooks: 19 | urls: 20 | - https://webhooks.gitter.im/e/acc2c57482e94b44f557 21 | on_success: change # options: [always|never|change] default: always 22 | on_failure: always # options: [always|never|change] default: always 23 | on_start: false # default: false 24 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Manuel Martínez-Almeida 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/binding.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import "net/http" 8 | 9 | const ( 10 | MIMEJSON = "application/json" 11 | MIMEHTML = "text/html" 12 | MIMEXML = "application/xml" 13 | MIMEXML2 = "text/xml" 14 | MIMEPlain = "text/plain" 15 | MIMEPOSTForm = "application/x-www-form-urlencoded" 16 | MIMEMultipartPOSTForm = "multipart/form-data" 17 | MIMEPROTOBUF = "application/x-protobuf" 18 | ) 19 | 20 | type Binding interface { 21 | Name() string 22 | Bind(*http.Request, interface{}) error 23 | } 24 | 25 | type StructValidator interface { 26 | // ValidateStruct can receive any kind of type and it should never panic, even if the configuration is not right. 27 | // If the received type is not a struct, any validation should be skipped and nil must be returned. 28 | // If the received type is a struct or pointer to a struct, the validation should be performed. 29 | // If the struct is not valid or the validation itself fails, a descriptive error should be returned. 30 | // Otherwise nil must be returned. 31 | ValidateStruct(interface{}) error 32 | } 33 | 34 | var Validator StructValidator = &defaultValidator{} 35 | 36 | var ( 37 | JSON = jsonBinding{} 38 | XML = xmlBinding{} 39 | Form = formBinding{} 40 | FormPost = formPostBinding{} 41 | FormMultipart = formMultipartBinding{} 42 | ProtoBuf = protobufBinding{} 43 | ) 44 | 45 | func Default(method, contentType string) Binding { 46 | if method == "GET" { 47 | return Form 48 | } else { 49 | switch contentType { 50 | case MIMEJSON: 51 | return JSON 52 | case MIMEXML, MIMEXML2: 53 | return XML 54 | case MIMEPROTOBUF: 55 | return ProtoBuf 56 | default: //case MIMEPOSTForm, MIMEMultipartPOSTForm: 57 | return Form 58 | } 59 | } 60 | } 61 | 62 | func validate(obj interface{}) error { 63 | if Validator == nil { 64 | return nil 65 | } 66 | return Validator.ValidateStruct(obj) 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/default_validator.go: -------------------------------------------------------------------------------- 1 | package binding 2 | 3 | import ( 4 | "reflect" 5 | "sync" 6 | 7 | "gopkg.in/go-playground/validator.v8" 8 | ) 9 | 10 | type defaultValidator struct { 11 | once sync.Once 12 | validate *validator.Validate 13 | } 14 | 15 | var _ StructValidator = &defaultValidator{} 16 | 17 | func (v *defaultValidator) ValidateStruct(obj interface{}) error { 18 | if kindOfData(obj) == reflect.Struct { 19 | v.lazyinit() 20 | if err := v.validate.Struct(obj); err != nil { 21 | return error(err) 22 | } 23 | } 24 | return nil 25 | } 26 | 27 | func (v *defaultValidator) lazyinit() { 28 | v.once.Do(func() { 29 | config := &validator.Config{TagName: "binding"} 30 | v.validate = validator.New(config) 31 | }) 32 | } 33 | 34 | func kindOfData(data interface{}) reflect.Kind { 35 | value := reflect.ValueOf(data) 36 | valueType := value.Kind() 37 | if valueType == reflect.Ptr { 38 | valueType = value.Elem().Kind() 39 | } 40 | return valueType 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/form.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import "net/http" 8 | 9 | type formBinding struct{} 10 | type formPostBinding struct{} 11 | type formMultipartBinding struct{} 12 | 13 | func (formBinding) Name() string { 14 | return "form" 15 | } 16 | 17 | func (formBinding) Bind(req *http.Request, obj interface{}) error { 18 | if err := req.ParseForm(); err != nil { 19 | return err 20 | } 21 | req.ParseMultipartForm(32 << 10) // 32 MB 22 | if err := mapForm(obj, req.Form); err != nil { 23 | return err 24 | } 25 | return validate(obj) 26 | } 27 | 28 | func (formPostBinding) Name() string { 29 | return "form-urlencoded" 30 | } 31 | 32 | func (formPostBinding) Bind(req *http.Request, obj interface{}) error { 33 | if err := req.ParseForm(); err != nil { 34 | return err 35 | } 36 | if err := mapForm(obj, req.PostForm); err != nil { 37 | return err 38 | } 39 | return validate(obj) 40 | } 41 | 42 | func (formMultipartBinding) Name() string { 43 | return "multipart/form-data" 44 | } 45 | 46 | func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error { 47 | if err := req.ParseMultipartForm(32 << 10); err != nil { 48 | return err 49 | } 50 | if err := mapForm(obj, req.MultipartForm.Value); err != nil { 51 | return err 52 | } 53 | return validate(obj) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import ( 8 | "encoding/json" 9 | 10 | "net/http" 11 | ) 12 | 13 | type jsonBinding struct{} 14 | 15 | func (jsonBinding) Name() string { 16 | return "json" 17 | } 18 | 19 | func (jsonBinding) Bind(req *http.Request, obj interface{}) error { 20 | decoder := json.NewDecoder(req.Body) 21 | if err := decoder.Decode(obj); err != nil { 22 | return err 23 | } 24 | return validate(obj) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/protobuf.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import ( 8 | "github.com/golang/protobuf/proto" 9 | 10 | "io/ioutil" 11 | "net/http" 12 | ) 13 | 14 | type protobufBinding struct{} 15 | 16 | func (_ protobufBinding) Name() string { 17 | return "protobuf" 18 | } 19 | 20 | func (_ protobufBinding) Bind(req *http.Request, obj interface{}) error { 21 | 22 | buf, err := ioutil.ReadAll(req.Body) 23 | if err != nil { 24 | return err 25 | } 26 | 27 | if err = proto.Unmarshal(buf, obj.(proto.Message)); err != nil { 28 | return err 29 | } 30 | 31 | //Here it's same to return validate(obj), but util now we cann't add `binding:""` to the struct 32 | //which automatically generate by gen-proto 33 | return nil 34 | //return validate(obj) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/binding/xml.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import ( 8 | "encoding/xml" 9 | "net/http" 10 | ) 11 | 12 | type xmlBinding struct{} 13 | 14 | func (xmlBinding) Name() string { 15 | return "xml" 16 | } 17 | 18 | func (xmlBinding) Bind(req *http.Request, obj interface{}) error { 19 | decoder := xml.NewDecoder(req.Body) 20 | if err := decoder.Decode(obj); err != nil { 21 | return err 22 | } 23 | return validate(obj) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "bytes" 9 | "html/template" 10 | "log" 11 | ) 12 | 13 | func init() { 14 | log.SetFlags(0) 15 | } 16 | 17 | // IsDebugging returns true if the framework is running in debug mode. 18 | // Use SetMode(gin.Release) to switch to disable the debug mode. 19 | func IsDebugging() bool { 20 | return ginMode == debugCode 21 | } 22 | 23 | func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) { 24 | if IsDebugging() { 25 | nuHandlers := len(handlers) 26 | handlerName := nameOfFunction(handlers.Last()) 27 | debugPrint("%-6s %-25s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers) 28 | } 29 | } 30 | 31 | func debugPrintLoadTemplate(tmpl *template.Template) { 32 | if IsDebugging() { 33 | var buf bytes.Buffer 34 | for _, tmpl := range tmpl.Templates() { 35 | buf.WriteString("\t- ") 36 | buf.WriteString(tmpl.Name()) 37 | buf.WriteString("\n") 38 | } 39 | debugPrint("Loaded HTML Templates (%d): \n%s\n", len(tmpl.Templates()), buf.String()) 40 | } 41 | } 42 | 43 | func debugPrint(format string, values ...interface{}) { 44 | if IsDebugging() { 45 | log.Printf("[GIN-debug] "+format, values...) 46 | } 47 | } 48 | 49 | func debugPrintWARNINGNew() { 50 | debugPrint(`[WARNING] Running in "debug" mode. Switch to "release" mode in production. 51 | - using env: export GIN_MODE=release 52 | - using code: gin.SetMode(gin.ReleaseMode) 53 | 54 | `) 55 | } 56 | 57 | func debugPrintWARNINGSetHTMLTemplate() { 58 | debugPrint(`[WARNING] Since SetHTMLTemplate() is NOT thread-safe. It should only be called 59 | at initialization. ie. before any route is registered or the router is listening in a socket: 60 | 61 | router := gin.Default() 62 | router.SetHTMLTemplate(template) // << good place 63 | 64 | `) 65 | } 66 | 67 | func debugPrintError(err error) { 68 | if err != nil { 69 | debugPrint("[ERROR] %v\n", err) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/deprecated.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import "log" 8 | 9 | func (c *Context) GetCookie(name string) (string, error) { 10 | log.Println("GetCookie() method is deprecated. Use Cookie() instead.") 11 | return c.Cookie(name) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/fs.go: -------------------------------------------------------------------------------- 1 | package gin 2 | 3 | import ( 4 | "net/http" 5 | "os" 6 | ) 7 | 8 | type ( 9 | onlyfilesFS struct { 10 | fs http.FileSystem 11 | } 12 | neuteredReaddirFile struct { 13 | http.File 14 | } 15 | ) 16 | 17 | // Dir returns a http.Filesystem that can be used by http.FileServer(). It is used interally 18 | // in router.Static(). 19 | // if listDirectory == true, then it works the same as http.Dir() otherwise it returns 20 | // a filesystem that prevents http.FileServer() to list the directory files. 21 | func Dir(root string, listDirectory bool) http.FileSystem { 22 | fs := http.Dir(root) 23 | if listDirectory { 24 | return fs 25 | } 26 | return &onlyfilesFS{fs} 27 | } 28 | 29 | // Conforms to http.Filesystem 30 | func (fs onlyfilesFS) Open(name string) (http.File, error) { 31 | f, err := fs.fs.Open(name) 32 | if err != nil { 33 | return nil, err 34 | } 35 | return neuteredReaddirFile{f}, nil 36 | } 37 | 38 | // Overrides the http.File default implementation 39 | func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) { 40 | // this disables directory listing 41 | return nil, nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intervention-engine/ie/543417b987f3862b6c197b5b12f6c3735856a67a/vendor/github.com/gin-gonic/gin/logo.jpg -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import ( 8 | "io" 9 | "os" 10 | 11 | "github.com/gin-gonic/gin/binding" 12 | ) 13 | 14 | const ENV_GIN_MODE = "GIN_MODE" 15 | 16 | const ( 17 | DebugMode string = "debug" 18 | ReleaseMode string = "release" 19 | TestMode string = "test" 20 | ) 21 | const ( 22 | debugCode = iota 23 | releaseCode = iota 24 | testCode = iota 25 | ) 26 | 27 | // DefaultWriter is the default io.Writer used the Gin for debug output and 28 | // middleware output like Logger() or Recovery(). 29 | // Note that both Logger and Recovery provides custom ways to configure their 30 | // output io.Writer. 31 | // To support coloring in Windows use: 32 | // import "github.com/mattn/go-colorable" 33 | // gin.DefaultWriter = colorable.NewColorableStdout() 34 | var DefaultWriter io.Writer = os.Stdout 35 | var DefaultErrorWriter io.Writer = os.Stderr 36 | 37 | var ginMode int = debugCode 38 | var modeName string = DebugMode 39 | 40 | func init() { 41 | mode := os.Getenv(ENV_GIN_MODE) 42 | if len(mode) == 0 { 43 | SetMode(DebugMode) 44 | } else { 45 | SetMode(mode) 46 | } 47 | } 48 | 49 | func SetMode(value string) { 50 | switch value { 51 | case DebugMode: 52 | ginMode = debugCode 53 | case ReleaseMode: 54 | ginMode = releaseCode 55 | case TestMode: 56 | ginMode = testCode 57 | default: 58 | panic("gin mode unknown: " + value) 59 | } 60 | modeName = value 61 | } 62 | 63 | func DisableBindValidation() { 64 | binding.Validator = nil 65 | } 66 | 67 | func Mode() string { 68 | return modeName 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/data.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import "net/http" 8 | 9 | type Data struct { 10 | ContentType string 11 | Data []byte 12 | } 13 | 14 | func (r Data) Render(w http.ResponseWriter) error { 15 | if len(r.ContentType) > 0 { 16 | w.Header()["Content-Type"] = []string{r.ContentType} 17 | } 18 | w.Write(r.Data) 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/html.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import ( 8 | "html/template" 9 | "net/http" 10 | ) 11 | 12 | type ( 13 | HTMLRender interface { 14 | Instance(string, interface{}) Render 15 | } 16 | 17 | HTMLProduction struct { 18 | Template *template.Template 19 | } 20 | 21 | HTMLDebug struct { 22 | Files []string 23 | Glob string 24 | } 25 | 26 | HTML struct { 27 | Template *template.Template 28 | Name string 29 | Data interface{} 30 | } 31 | ) 32 | 33 | var htmlContentType = []string{"text/html; charset=utf-8"} 34 | 35 | func (r HTMLProduction) Instance(name string, data interface{}) Render { 36 | return HTML{ 37 | Template: r.Template, 38 | Name: name, 39 | Data: data, 40 | } 41 | } 42 | 43 | func (r HTMLDebug) Instance(name string, data interface{}) Render { 44 | return HTML{ 45 | Template: r.loadTemplate(), 46 | Name: name, 47 | Data: data, 48 | } 49 | } 50 | func (r HTMLDebug) loadTemplate() *template.Template { 51 | if len(r.Files) > 0 { 52 | return template.Must(template.ParseFiles(r.Files...)) 53 | } 54 | if len(r.Glob) > 0 { 55 | return template.Must(template.ParseGlob(r.Glob)) 56 | } 57 | panic("the HTML debug render was created without files or glob pattern") 58 | } 59 | 60 | func (r HTML) Render(w http.ResponseWriter) error { 61 | writeContentType(w, htmlContentType) 62 | if len(r.Name) == 0 { 63 | return r.Template.Execute(w, r.Data) 64 | } else { 65 | return r.Template.ExecuteTemplate(w, r.Name, r.Data) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import ( 8 | "encoding/json" 9 | "net/http" 10 | ) 11 | 12 | type ( 13 | JSON struct { 14 | Data interface{} 15 | } 16 | 17 | IndentedJSON struct { 18 | Data interface{} 19 | } 20 | ) 21 | 22 | var jsonContentType = []string{"application/json; charset=utf-8"} 23 | 24 | func (r JSON) Render(w http.ResponseWriter) error { 25 | return WriteJSON(w, r.Data) 26 | } 27 | 28 | func (r IndentedJSON) Render(w http.ResponseWriter) error { 29 | writeContentType(w, jsonContentType) 30 | jsonBytes, err := json.MarshalIndent(r.Data, "", " ") 31 | if err != nil { 32 | return err 33 | } 34 | w.Write(jsonBytes) 35 | return nil 36 | } 37 | 38 | func WriteJSON(w http.ResponseWriter, obj interface{}) error { 39 | writeContentType(w, jsonContentType) 40 | return json.NewEncoder(w).Encode(obj) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/redirect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import ( 8 | "fmt" 9 | "net/http" 10 | ) 11 | 12 | type Redirect struct { 13 | Code int 14 | Request *http.Request 15 | Location string 16 | } 17 | 18 | func (r Redirect) Render(w http.ResponseWriter) error { 19 | if (r.Code < 300 || r.Code > 308) && r.Code != 201 { 20 | panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code)) 21 | } 22 | http.Redirect(w, r.Request, r.Location, r.Code) 23 | return nil 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/render.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import "net/http" 8 | 9 | type Render interface { 10 | Render(http.ResponseWriter) error 11 | } 12 | 13 | var ( 14 | _ Render = JSON{} 15 | _ Render = IndentedJSON{} 16 | _ Render = XML{} 17 | _ Render = String{} 18 | _ Render = Redirect{} 19 | _ Render = Data{} 20 | _ Render = HTML{} 21 | _ HTMLRender = HTMLDebug{} 22 | _ HTMLRender = HTMLProduction{} 23 | ) 24 | 25 | func writeContentType(w http.ResponseWriter, value []string) { 26 | header := w.Header() 27 | if val := header["Content-Type"]; len(val) == 0 { 28 | header["Content-Type"] = value 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/text.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "net/http" 11 | ) 12 | 13 | type String struct { 14 | Format string 15 | Data []interface{} 16 | } 17 | 18 | var plainContentType = []string{"text/plain; charset=utf-8"} 19 | 20 | func (r String) Render(w http.ResponseWriter) error { 21 | WriteString(w, r.Format, r.Data) 22 | return nil 23 | } 24 | 25 | func WriteString(w http.ResponseWriter, format string, data []interface{}) { 26 | writeContentType(w, plainContentType) 27 | 28 | if len(data) > 0 { 29 | fmt.Fprintf(w, format, data...) 30 | } else { 31 | io.WriteString(w, format) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/render/xml.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package render 6 | 7 | import ( 8 | "encoding/xml" 9 | "net/http" 10 | ) 11 | 12 | type XML struct { 13 | Data interface{} 14 | } 15 | 16 | var xmlContentType = []string{"application/xml; charset=utf-8"} 17 | 18 | func (r XML) Render(w http.ResponseWriter) error { 19 | writeContentType(w, xmlContentType) 20 | return xml.NewEncoder(w).Encode(r.Data) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/test_helpers.go: -------------------------------------------------------------------------------- 1 | package gin 2 | 3 | import ( 4 | "net/http/httptest" 5 | ) 6 | 7 | func CreateTestContext() (c *Context, w *httptest.ResponseRecorder, r *Engine) { 8 | w = httptest.NewRecorder() 9 | r = New() 10 | c = r.allocateContext() 11 | c.reset() 12 | c.writermem.reset(w) 13 | return 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/gin-gonic/gin/wercker.yml: -------------------------------------------------------------------------------- 1 | box: wercker/default -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C testdata 42 | protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto 43 | make 44 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | go: 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - tip 9 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= 3 | [![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) 4 | 5 | gorilla/context is a general purpose registry for global request variables. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/context 8 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | go: 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - tip 9 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package securecookie 4 | 5 | var hashKey = []byte("very-secret12345") 6 | var blockKey = []byte("a-lot-secret1234") 7 | var s = New(hashKey, blockKey) 8 | 9 | type Cookie struct { 10 | B bool 11 | I int 12 | S string 13 | } 14 | 15 | func Fuzz(data []byte) int { 16 | datas := string(data) 17 | var c Cookie 18 | if err := s.Decode("fuzz", datas, &c); err != nil { 19 | return 0 20 | } 21 | if _, err := s.Encode("fuzz", c); err != nil { 22 | panic(err) 23 | } 24 | return 1 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | go: 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - tip 9 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | .DS_Store 26 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | 4 | go: 5 | - 1.1 6 | - 1.2 7 | - 1.3 8 | - 1.4 9 | - tip 10 | 11 | install: 12 | - go get -v -d ./... 13 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Dmitry Afanasyev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/addresses.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | import "strconv" 4 | 5 | // Continent generates random continent 6 | func Continent() string { 7 | return lookup(lang, "continents", true) 8 | } 9 | 10 | // Country generates random country 11 | func Country() string { 12 | return lookup(lang, "countries", true) 13 | } 14 | 15 | // City generates random city 16 | func City() string { 17 | city := lookup(lang, "cities", true) 18 | switch r.Intn(5) { 19 | case 0: 20 | return join(cityPrefix(), city) 21 | case 1: 22 | return join(city, citySuffix()) 23 | default: 24 | return city 25 | } 26 | } 27 | 28 | func cityPrefix() string { 29 | return lookup(lang, "city_prefixes", false) 30 | } 31 | 32 | func citySuffix() string { 33 | return lookup(lang, "city_suffixes", false) 34 | } 35 | 36 | // State generates random state 37 | func State() string { 38 | return lookup(lang, "states", false) 39 | } 40 | 41 | // StateAbbrev generates random state abbreviation 42 | func StateAbbrev() string { 43 | return lookup(lang, "state_abbrevs", false) 44 | } 45 | 46 | // Street generates random street name 47 | func Street() string { 48 | street := lookup(lang, "streets", true) 49 | return join(street, streetSuffix()) 50 | } 51 | 52 | // StreetAddress generates random street name along with building number 53 | func StreetAddress() string { 54 | return join(Street(), strconv.Itoa(r.Intn(100))) 55 | } 56 | 57 | func streetSuffix() string { 58 | return lookup(lang, "street_suffixes", true) 59 | } 60 | 61 | // Zip generates random zip code using one of the formats specifies in zip_format file 62 | func Zip() string { 63 | return generate(lang, "zips", true) 64 | } 65 | 66 | // Phone generates random phone number using one of the formats format specified in phone_format file 67 | func Phone() string { 68 | return generate(lang, "phones", true) 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/credit_cards.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | import ( 4 | "strings" 5 | 6 | "strconv" 7 | ) 8 | 9 | type creditCard struct { 10 | vendor string 11 | length int 12 | prefixes []int 13 | } 14 | 15 | var creditCards = map[string]creditCard{ 16 | "visa": {"VISA", 16, []int{4539, 4556, 4916, 4532, 4929, 40240071, 4485, 4716, 4}}, 17 | "mastercard": {"MasterCard", 16, []int{51, 52, 53, 54, 55}}, 18 | "amex": {"American Express", 15, []int{34, 37}}, 19 | "discover": {"Discover", 16, []int{6011}}, 20 | } 21 | 22 | // CreditCardType returns one of the following credit values: 23 | // VISA, MasterCard, American Express and Discover 24 | func CreditCardType() string { 25 | n := len(creditCards) 26 | var vendors []string 27 | for _, cc := range creditCards { 28 | vendors = append(vendors, cc.vendor) 29 | } 30 | 31 | return vendors[r.Intn(n)] 32 | } 33 | 34 | // CreditCardNum generated credit card number according to the card number rules 35 | func CreditCardNum(vendor string) string { 36 | if vendor != "" { 37 | vendor = strings.ToLower(vendor) 38 | } else { 39 | var vendors []string 40 | for v := range creditCards { 41 | vendors = append(vendors, v) 42 | } 43 | vendor = vendors[r.Intn(len(vendors))] 44 | } 45 | card := creditCards[vendor] 46 | prefix := strconv.Itoa(card.prefixes[r.Intn(len(card.prefixes))]) 47 | num := []rune(prefix) 48 | for i := 0; i < card.length-len(prefix); i++ { 49 | num = append(num, genCCDigit(num)) 50 | } 51 | return string(num) 52 | } 53 | 54 | func genCCDigit(num []rune) rune { 55 | sum := 0 56 | for i := len(num) - 1; i >= 0; i-- { 57 | n := int(num[i]) 58 | if i%2 != 0 { 59 | sum += n 60 | } else { 61 | if n*2 > 9 { 62 | sum += n*2 - 9 63 | } else { 64 | sum += n * 2 65 | } 66 | } 67 | } 68 | return rune(((sum/10+1)*10 - sum) % 10) 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/currencies.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | // Currency generates currency name 4 | func Currency() string { 5 | return lookup(lang, "currencies", true) 6 | } 7 | 8 | // CurrencyCode generates currency code 9 | func CurrencyCode() string { 10 | return lookup(lang, "currency_codes", true) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/dates.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | // Day generates day of the month 4 | func Day() int { 5 | return r.Intn(31) + 1 6 | } 7 | 8 | // WeekDay generates name ot the week day 9 | func WeekDay() string { 10 | return lookup(lang, "weekdays", true) 11 | } 12 | 13 | // WeekDayShort generates abbreviated name of the week day 14 | func WeekDayShort() string { 15 | return lookup(lang, "weekdays_short", true) 16 | } 17 | 18 | // WeekdayNum generates number of the day of the week 19 | func WeekdayNum() int { 20 | return r.Intn(7) + 1 21 | } 22 | 23 | // Month generates month name 24 | func Month() string { 25 | return lookup(lang, "months", true) 26 | } 27 | 28 | // MonthShort generates abbreviated month name 29 | func MonthShort() string { 30 | return lookup(lang, "months_short", true) 31 | } 32 | 33 | // MonthNum generates month number (from 1 to 12) 34 | func MonthNum() int { 35 | return r.Intn(12) + 1 36 | } 37 | 38 | // Year generates year using the given boundaries 39 | func Year(from, to int) int { 40 | n := r.Intn(to-from) + 1 41 | return from + n 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/geo.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | // Latitute generates latitude 4 | func Latitute() float32 { 5 | return r.Float32() * 180 / 90 6 | } 7 | 8 | // LatitudeDegress generates latitude degrees (from -180 to 180) 9 | func LatitudeDegress() int { 10 | return r.Intn(360) - 180 11 | } 12 | 13 | // LatitudeMinutes generates latitude minutes (from 0 to 60) 14 | func LatitudeMinutes() int { 15 | return r.Intn(60) 16 | } 17 | 18 | // LatitudeSeconds generates latitude seconds (from 0 to 60) 19 | func LatitudeSeconds() int { 20 | return r.Intn(60) 21 | } 22 | 23 | // LatitudeDirection generates latitude direction (N(orth) o S(outh)) 24 | func LatitudeDirection() string { 25 | if r.Intn(2) == 0 { 26 | return "N" 27 | } 28 | return "S" 29 | } 30 | 31 | // Longitude generates longitude 32 | func Longitude() float32 { 33 | return r.Float32()*360 - 180 34 | } 35 | 36 | // LongitudeDegrees generates longitude degrees (from -180 to 180) 37 | func LongitudeDegrees() int { 38 | return r.Intn(360) - 180 39 | } 40 | 41 | // LongitudeMinutes generates (from 0 to 60) 42 | func LongitudeMinutes() int { 43 | return r.Intn(60) 44 | } 45 | 46 | // LongitudeSeconds generates (from 0 to 60) 47 | func LongitudeSeconds() int { 48 | return r.Intn(60) 49 | } 50 | 51 | // LongitudeDirection generates (W(est) or E(ast)) 52 | func LongitudeDirection() string { 53 | if r.Intn(2) == 0 { 54 | return "W" 55 | } 56 | return "E" 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/internet.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | import ( 4 | "strconv" 5 | "strings" 6 | ) 7 | 8 | // UserName generates user name in one of the following forms 9 | // first name + last name, letter + last names or concatenation of from 1 to 3 lowercased words 10 | func UserName() string { 11 | gender := randGender() 12 | switch r.Intn(3) { 13 | case 0: 14 | return lookup("en", gender+"_first_names", false) + lookup(lang, gender+"_last_names", false) 15 | case 1: 16 | return Character() + lookup(lang, gender+"_last_names", false) 17 | default: 18 | return strings.Replace(WordsN(r.Intn(3)+1), " ", "_", -1) 19 | } 20 | } 21 | 22 | // TopLevelDomain generates random top level domain 23 | func TopLevelDomain() string { 24 | return lookup(lang, "top_level_domains", true) 25 | } 26 | 27 | // DomainName generates random domain name 28 | func DomainName() string { 29 | return Company() + "." + TopLevelDomain() 30 | } 31 | 32 | // EmailAddress generates email address 33 | func EmailAddress() string { 34 | return UserName() + "@" + DomainName() 35 | } 36 | 37 | // EmailSubject generates random email subject 38 | func EmailSubject() string { 39 | return Sentence() 40 | } 41 | 42 | // EmailBody generates random email body 43 | func EmailBody() string { 44 | return Paragraphs() 45 | } 46 | 47 | // DomainZone generates random domain zone 48 | func DomainZone() string { 49 | return lookup(lang, "domain_zones", true) 50 | } 51 | 52 | // IPv4 generates IPv4 address 53 | func IPv4() string { 54 | ip := make([]string, 4) 55 | for i := 0; i < 4; i++ { 56 | ip[i] = strconv.Itoa(r.Intn(256)) 57 | } 58 | return strings.Join(ip, ".") 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/jobs.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | // Company generates company name 4 | func Company() string { 5 | return lookup(lang, "companies", true) 6 | } 7 | 8 | // JobTitle generates job title 9 | func JobTitle() string { 10 | job := lookup(lang, "jobs", true) 11 | return join(job, jobTitleSuffix()) 12 | } 13 | 14 | func jobTitleSuffix() string { 15 | return lookup(lang, "jobs_suffixes", false) 16 | } 17 | 18 | // Industry generates industry name 19 | func Industry() string { 20 | return lookup(lang, "industries", true) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/personal.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | // Gender generates random gender 8 | func Gender() string { 9 | return lookup(lang, "genders", true) 10 | } 11 | 12 | // GenderAbbrev returns first downcased letter of the random gender 13 | func GenderAbbrev() string { 14 | g := Gender() 15 | if g != "" { 16 | return strings.ToLower(string(g[0])) 17 | } 18 | return "" 19 | } 20 | 21 | // Language generates random human language 22 | func Language() string { 23 | return lookup(lang, "languages", true) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/icrowley/fake/products.go: -------------------------------------------------------------------------------- 1 | package fake 2 | 3 | // Brand generates brand name 4 | func Brand() string { 5 | return Company() 6 | } 7 | 8 | // ProductName generates product name 9 | func ProductName() string { 10 | productName := lookup(lang, "adjectives", true) + " " + lookup(lang, "nouns", true) 11 | if r.Intn(2) == 1 { 12 | productName = lookup(lang, "adjectives", true) + " " + productName 13 | } 14 | return productName 15 | } 16 | 17 | // Product generates product title as brand + product name 18 | func Product() string { 19 | return Brand() + " " + ProductName() 20 | } 21 | 22 | // Model generates model name that consists of letters and digits, optionally with a hyphen between them 23 | func Model() string { 24 | seps := []string{"", " ", "-"} 25 | return CharactersN(r.Intn(3)+1) + seps[r.Intn(len(seps))] + Digits() 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/annotation.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Annotation struct { 30 | AuthorReference *Reference `bson:"authorReference,omitempty" json:"authorReference,omitempty"` 31 | AuthorString string `bson:"authorString,omitempty" json:"authorString,omitempty"` 32 | Time *FHIRDateTime `bson:"time,omitempty" json:"time,omitempty"` 33 | Text string `bson:"text,omitempty" json:"text,omitempty"` 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/backboneelement.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type BackboneElement struct { 30 | Element `bson:",inline"` 31 | ModifierExtension []Extension `bson:"modifierExtension,omitempty" json:"modifierExtension,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/codeableconcept.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type CodeableConcept struct { 30 | Coding []Coding `bson:"coding,omitempty" json:"coding,omitempty"` 31 | Text string `bson:"text,omitempty" json:"text,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/codeableconcept_ext.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | type CodeableConcepts []CodeableConcept 4 | 5 | func (slice CodeableConcepts) AnyMatchesCode(system string, code string) bool { 6 | for _, concept := range slice { 7 | if concept.MatchesCode(system, code) { 8 | return true 9 | } 10 | } 11 | return false 12 | } 13 | 14 | func (slice CodeableConcepts) AnyMatchesAnyCode(codings []Coding) bool { 15 | for _, coding := range codings { 16 | if slice.AnyMatchesCode(coding.System, coding.Code) { 17 | return true 18 | } 19 | } 20 | return false 21 | } 22 | 23 | /* 24 | func AnyCodeableConceptMatchesCode(concepts []CodeableConcept, system string, code string) bool { 25 | for _, concept := range concepts { 26 | if concept.MatchesCode(system, code) { 27 | return true 28 | } 29 | } 30 | return false 31 | } 32 | */ 33 | 34 | func (c *CodeableConcept) MatchesCode(system string, code string) bool { 35 | for _, coding := range c.Coding { 36 | if coding.System == system && coding.Code == code { 37 | return true 38 | } 39 | } 40 | return false 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/coding.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Coding struct { 30 | System string `bson:"system,omitempty" json:"system,omitempty"` 31 | Version string `bson:"version,omitempty" json:"version,omitempty"` 32 | Code string `bson:"code,omitempty" json:"code,omitempty"` 33 | Display string `bson:"display,omitempty" json:"display,omitempty"` 34 | UserSelected *bool `bson:"userSelected,omitempty" json:"userSelected,omitempty"` 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/constructors.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | // This file contains manually generated convenience constructors for our 4 | // models. 5 | 6 | // NewOperationOutcome creates a pointer to an OperationOutcome and sets the 7 | // severity, code and diagnostics for the first issue. 8 | func NewOperationOutcome(severity, code, diagnostics string) *OperationOutcome { 9 | return &OperationOutcome{ 10 | Issue: []OperationOutcomeIssueComponent{ 11 | OperationOutcomeIssueComponent{ 12 | Severity: severity, 13 | Code: code, 14 | Diagnostics: diagnostics, 15 | }, 16 | }, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/contactpoint.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type ContactPoint struct { 30 | System string `bson:"system,omitempty" json:"system,omitempty"` 31 | Value string `bson:"value,omitempty" json:"value,omitempty"` 32 | Use string `bson:"use,omitempty" json:"use,omitempty"` 33 | Rank *uint32 `bson:"rank,omitempty" json:"rank,omitempty"` 34 | Period *Period `bson:"period,omitempty" json:"period,omitempty"` 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/element.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Element struct { 30 | Id string `bson:"_id,omitempty" json:"id,omitempty"` 31 | Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/fhirdatetime.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "encoding/json" 5 | "time" 6 | ) 7 | 8 | type Precision string 9 | 10 | const ( 11 | Date = "date" 12 | Timestamp = "timestamp" 13 | ) 14 | 15 | type FHIRDateTime struct { 16 | Time time.Time 17 | Precision Precision 18 | } 19 | 20 | func (f *FHIRDateTime) UnmarshalJSON(data []byte) (err error) { 21 | if len(data) <= 12 { 22 | f.Precision = Precision("date") 23 | f.Time, err = time.ParseInLocation("\"2006-01-02\"", string(data), time.Local) 24 | } else { 25 | f.Precision = Precision("timestamp") 26 | f.Time = time.Time{} 27 | f.Time.UnmarshalJSON(data) 28 | } 29 | return err 30 | } 31 | 32 | func (f FHIRDateTime) MarshalJSON() ([]byte, error) { 33 | if f.Precision == Timestamp { 34 | return json.Marshal(f.Time.Format(time.RFC3339)) 35 | } else { 36 | return json.Marshal(f.Time.Format("2006-01-02")) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/narrative.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Narrative struct { 30 | Status string `bson:"status,omitempty" json:"status,omitempty"` 31 | Div string `bson:"div,omitempty" json:"div,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/operationoutcome_ext.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "strings" 7 | ) 8 | 9 | func (o *OperationOutcome) Error() string { 10 | if len(o.Issue) == 0 { 11 | return "Unspecified OperationOutome" 12 | } 13 | 14 | messages := make([]string, len(o.Issue)) 15 | for i := range o.Issue { 16 | var buffer bytes.Buffer 17 | buffer.WriteString(fmt.Sprintf("[%s] %s: ", o.Issue[i].Severity, o.Issue[i].Code)) 18 | if o.Issue[i].Details != nil { 19 | d := o.Issue[i].Details 20 | if d.Text != "" { 21 | buffer.WriteString(o.Issue[i].Details.Text) 22 | } else if len(d.Coding) > 0 && d.Coding[0].Display != "" { 23 | buffer.WriteString(d.Coding[0].Display) 24 | } 25 | } 26 | if o.Issue[i].Diagnostics != "" { 27 | buffer.WriteString(fmt.Sprintf(" (dx: %s)", o.Issue[i].Diagnostics)) 28 | } 29 | messages[i] = buffer.String() 30 | } 31 | 32 | return strings.Join(messages, "\n") 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/period.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Period struct { 30 | Start *FHIRDateTime `bson:"start,omitempty" json:"start,omitempty"` 31 | End *FHIRDateTime `bson:"end,omitempty" json:"end,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/quantity.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Quantity struct { 30 | Value *float64 `bson:"value,omitempty" json:"value,omitempty"` 31 | Comparator string `bson:"comparator,omitempty" json:"comparator,omitempty"` 32 | Unit string `bson:"unit,omitempty" json:"unit,omitempty"` 33 | System string `bson:"system,omitempty" json:"system,omitempty"` 34 | Code string `bson:"code,omitempty" json:"code,omitempty"` 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/range.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Range struct { 30 | Low *Quantity `bson:"low,omitempty" json:"low,omitempty"` 31 | High *Quantity `bson:"high,omitempty" json:"high,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/ratio.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Ratio struct { 30 | Numerator *Quantity `bson:"numerator,omitempty" json:"numerator,omitempty"` 31 | Denominator *Quantity `bson:"denominator,omitempty" json:"denominator,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/reference.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2014, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Reference struct { 30 | Reference string `bson:"reference,omitempty" json:"reference,omitempty"` 31 | Display string `bson:"display,omitempty" json:"display,omitempty"` 32 | Type string `bson:"type,omitempty" json:"type,omitempty"` 33 | ReferencedID string `bson:"referenceid,omitempty" json:"referenceid,omitempty"` 34 | External *bool `bson:"external,omitempty" json:"external,omitempty"` 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/reference_ext.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | ) 7 | 8 | func (r *Reference) MarshalJSON() ([]byte, error) { 9 | m := map[string]string{ 10 | "reference": r.Reference, 11 | } 12 | if r.Display != "" { 13 | m["display"] = r.Display 14 | } 15 | return json.Marshal(m) 16 | } 17 | 18 | type reference Reference 19 | 20 | func (r *Reference) UnmarshalJSON(data []byte) (err error) { 21 | ref := reference{} 22 | if err = json.Unmarshal(data, &ref); err == nil { 23 | splitURL := strings.Split(ref.Reference, "/") 24 | if len(splitURL) >= 2 { 25 | ref.ReferencedID = splitURL[len(splitURL)-1] 26 | ref.Type = splitURL[len(splitURL)-2] 27 | } 28 | external := strings.HasPrefix(ref.Reference, "http") 29 | ref.External = &external 30 | *r = Reference(ref) 31 | return 32 | } 33 | return err 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/models/resource.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2015, HL7, Inc & The MITRE Corporation 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modification, 5 | // are permitted provided that the following conditions are met: 6 | // 7 | // * Redistributions of source code must retain the above copyright notice, this 8 | // list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // * Neither the name of HL7 nor the names of its contributors may be used to 13 | // endorse or promote products derived from this software without specific 14 | // prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | // POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package models 28 | 29 | type Resource struct { 30 | ResourceType string `bson:"resourceType,omitempty" json:"resourceType,omitempty"` 31 | Id string `bson:"_id,omitempty" json:"id,omitempty"` 32 | Meta *Meta `bson:"meta,omitempty" json:"meta,omitempty"` 33 | ImplicitRules string `bson:"implicitRules,omitempty" json:"implicitRules,omitempty"` 34 | Language string `bson:"language,omitempty" json:"language,omitempty"` 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/search/mongo_registry.go: -------------------------------------------------------------------------------- 1 | package search 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | 7 | "gopkg.in/mgo.v2/bson" 8 | ) 9 | 10 | var mongoRegistry *MongoRegistry 11 | var mongoRegistryOnce sync.Once 12 | 13 | // GlobalMongoRegistry returns an instance of the global search parameter registry 14 | func GlobalMongoRegistry() *MongoRegistry { 15 | mongoRegistryOnce.Do(func() { 16 | mongoRegistry = new(MongoRegistry) 17 | mongoRegistry.builders = make(map[string]BSONBuilder) 18 | }) 19 | return mongoRegistry 20 | } 21 | 22 | // MongoRegistry supports the registration and lookup of Mongo search parameter implementations as BSON builders. 23 | type MongoRegistry struct { 24 | buildersLock sync.RWMutex 25 | builders map[string]BSONBuilder 26 | } 27 | 28 | // RegisterBSONBuilder registers a BSON builder for a given parameter type. 29 | func (r *MongoRegistry) RegisterBSONBuilder(paramType string, builder BSONBuilder) { 30 | r.buildersLock.Lock() 31 | defer r.buildersLock.Unlock() 32 | r.builders[paramType] = builder 33 | } 34 | 35 | // LookupBSONBuilder looks up a BSON builder by type. If no builder is registered, it will return an error. 36 | func (r *MongoRegistry) LookupBSONBuilder(paramType string) (builder BSONBuilder, err error) { 37 | r.buildersLock.RLock() 38 | defer r.buildersLock.RUnlock() 39 | b, ok := r.builders[paramType] 40 | if !ok { 41 | return nil, fmt.Errorf("Could not find BSON builder for %s", paramType) 42 | } 43 | return b, nil 44 | } 45 | 46 | // BSONBuilder returns a BSON object representing the passed in search parameter. This BSON object is expected to be 47 | // merged with other objects and passed into Mongo's Find function. 48 | type BSONBuilder func(param SearchParam, searcher *MongoSearcher) (object bson.M, err error) 49 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/server/bind.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | "github.com/gin-gonic/gin/binding" 6 | ) 7 | 8 | const ( 9 | MIMEJSONFHIR = "application/json+fhir" 10 | MIMEXMLFHIR = "application/xml+fhir" 11 | ) 12 | 13 | func FHIRBind(c *gin.Context, obj interface{}) error { 14 | if c.Request.Method == "GET" { 15 | return c.BindWith(obj, binding.Form) 16 | } 17 | switch c.ContentType() { 18 | case MIMEJSONFHIR: 19 | return c.BindJSON(obj) 20 | case MIMEXMLFHIR: 21 | return c.BindWith(obj, binding.XML) 22 | } 23 | return c.Bind(obj) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/server/config.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/intervention-engine/fhir/auth" 5 | "gopkg.in/mgo.v2" 6 | ) 7 | 8 | // Although we got rid of the global in the fhir package, the ie project still needs it 9 | // Once ie removes the dependency on the global, this should go away 10 | var Database *mgo.Database 11 | 12 | // DefaultConfig is the default server configuration 13 | var DefaultConfig = Config{ 14 | ServerURL: "http://localhost:3001", 15 | IndexConfigPath: "config/indexes.conf", 16 | DatabaseName: "fhir", 17 | Auth: auth.None(), 18 | } 19 | 20 | // Config is used to hold information about the configuration of the FHIR 21 | // server. 22 | type Config struct { 23 | // ServerURL is the full URL for the root of the server. This may be used 24 | // by other middleware to compute redirect URLs 25 | ServerURL string 26 | // Auth determines what, if any authentication and authorization will be used 27 | // by the FHIR server 28 | Auth auth.Config 29 | // IndexConfigPath is the path to an indexes.conf configuration file, specifying 30 | // what mongo indexes the server should create (or verify) on startup 31 | IndexConfigPath string 32 | // DatabaseName is the name of the mongo database used for the fhir database. 33 | // Typically this will be the DefaultDatabaseName 34 | DatabaseName string 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/server/request_logger.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "bytes" 5 | "io/ioutil" 6 | "log" 7 | 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | // RequestLoggerHandler is a handler intended to be used during debugging to log out the request details including 12 | // the request headers and the request body. This should not be used in production as it has performance implications. 13 | func RequestLoggerHandler(c *gin.Context) { 14 | if c.Request != nil { 15 | 16 | buf, _ := ioutil.ReadAll(c.Request.Body) 17 | c.Request.Body.Close() 18 | 19 | log.Println("-----------------------------------------------------------------------------------------------------") 20 | log.Println("REQUEST HEADERS:") 21 | for k, v := range c.Request.Header { 22 | log.Printf("\t%s: %s\n", k, v) 23 | } 24 | log.Printf("\nREQUEST BODY:\n%s\n", buf) 25 | log.Println("-----------------------------------------------------------------------------------------------------") 26 | 27 | c.Request.Body = ioutil.NopCloser(bytes.NewReader(buf)) 28 | } 29 | c.Next() 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/intervention-engine/fhir/server/server_setup.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "log" 5 | "time" 6 | 7 | "github.com/gin-gonic/gin" 8 | "github.com/itsjamie/gin-cors" 9 | "gopkg.in/mgo.v2" 10 | ) 11 | 12 | type AfterRoutes func(*gin.Engine) 13 | 14 | type FHIRServer struct { 15 | DatabaseHost string 16 | Engine *gin.Engine 17 | MiddlewareConfig map[string][]gin.HandlerFunc 18 | AfterRoutes []AfterRoutes 19 | } 20 | 21 | func (f *FHIRServer) AddMiddleware(key string, middleware gin.HandlerFunc) { 22 | f.MiddlewareConfig[key] = append(f.MiddlewareConfig[key], middleware) 23 | } 24 | 25 | func NewServer(databaseHost string) *FHIRServer { 26 | server := &FHIRServer{DatabaseHost: databaseHost, MiddlewareConfig: make(map[string][]gin.HandlerFunc)} 27 | server.Engine = gin.Default() 28 | 29 | server.Engine.Use(cors.Middleware(cors.Config{ 30 | Origins: "*", 31 | Methods: "GET, PUT, POST, DELETE", 32 | RequestHeaders: "Origin, Authorization, Content-Type, If-Match, If-None-Exist", 33 | ExposedHeaders: "Location, ETag, Last-Modified", 34 | MaxAge: 86400 * time.Second, // Preflight expires after 1 day 35 | Credentials: true, 36 | ValidateHeaders: false, 37 | })) 38 | 39 | return server 40 | } 41 | 42 | func (f *FHIRServer) Run(config Config) { 43 | var err error 44 | 45 | // Setup the database 46 | session, err := mgo.Dial(f.DatabaseHost) 47 | if err != nil { 48 | panic(err) 49 | } 50 | log.Println("Connected to mongodb") 51 | defer session.Close() 52 | 53 | Database = session.DB(config.DatabaseName) 54 | 55 | RegisterRoutes(f.Engine, f.MiddlewareConfig, NewMongoDataAccessLayer(Database), config) 56 | 57 | indexSession := session.Copy() 58 | ConfigureIndexes(indexSession, config) 59 | indexSession.Close() 60 | 61 | for _, ar := range f.AfterRoutes { 62 | ar(f.Engine) 63 | } 64 | 65 | f.Engine.Run(":3001") 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/itsjamie/gin-cors/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /vendor/github.com/itsjamie/gin-cors/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - tip 5 | before_install: 6 | - go get github.com/axw/gocov/gocov 7 | - go get github.com/mattn/goveralls 8 | - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi 9 | script: 10 | - $HOME/gopath/bin/goveralls -service=travis-ci -------------------------------------------------------------------------------- /vendor/github.com/itsjamie/gin-cors/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jamie Stackhouse 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/juju/errors/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | -------------------------------------------------------------------------------- /vendor/github.com/juju/errors/Makefile: -------------------------------------------------------------------------------- 1 | default: check 2 | 3 | check: 4 | go test && go test -compiler gccgo 5 | 6 | docs: 7 | godoc2md github.com/juju/errors > README.md 8 | sed -i 's|\[godoc-link-here\]|[![GoDoc](https://godoc.org/github.com/juju/errors?status.svg)](https://godoc.org/github.com/juju/errors)|' README.md 9 | 10 | 11 | .PHONY: default check docs 12 | -------------------------------------------------------------------------------- /vendor/github.com/juju/errors/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013, 2014 Canonical Ltd. 2 | // Licensed under the LGPLv3, see LICENCE file for details. 3 | 4 | package errors 5 | 6 | import ( 7 | "runtime" 8 | "strings" 9 | ) 10 | 11 | // prefixSize is used internally to trim the user specific path from the 12 | // front of the returned filenames from the runtime call stack. 13 | var prefixSize int 14 | 15 | // goPath is the deduced path based on the location of this file as compiled. 16 | var goPath string 17 | 18 | func init() { 19 | _, file, _, ok := runtime.Caller(0) 20 | if file == "?" { 21 | return 22 | } 23 | if ok { 24 | // We know that the end of the file should be: 25 | // github.com/juju/errors/path.go 26 | size := len(file) 27 | suffix := len("github.com/juju/errors/path.go") 28 | goPath = file[:size-suffix] 29 | prefixSize = len(goPath) 30 | } 31 | } 32 | 33 | func trimGoPath(filename string) string { 34 | if strings.HasPrefix(filename, goPath) { 35 | return filename[prefixSize:] 36 | } 37 | return filename 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/manucorporat/sse/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.3 5 | - 1.4 6 | - tip 7 | -------------------------------------------------------------------------------- /vendor/github.com/manucorporat/sse/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Manuel Martínez-Almeida 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/manucorporat/sse/README.md: -------------------------------------------------------------------------------- 1 | #Server-Sent Events [![GoDoc](https://godoc.org/github.com/manucorporat/sse?status.svg)](https://godoc.org/github.com/manucorporat/sse) [![Build Status](https://travis-ci.org/manucorporat/sse.svg)](https://travis-ci.org/manucorporat/sse) 2 | 3 | Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is [standardized as part of HTML5[1] by the W3C](http://www.w3.org/TR/2009/WD-eventsource-20091029/). 4 | 5 | - [Real world demostration using Gin](http://sse.getgin.io/) 6 | - [Read this great SSE introduction by the HTML5Rocks guys](http://www.html5rocks.com/en/tutorials/eventsource/basics/) 7 | - [Browser support](http://caniuse.com/#feat=eventsource) 8 | 9 | ##Sample code 10 | 11 | ```go 12 | import "github.com/manucorporat/sse" 13 | 14 | func httpHandler(w http.ResponseWriter, req *http.Request) { 15 | // data can be a primitive like a string, an integer or a float 16 | sse.Encode(w, sse.Event{ 17 | Event: "message", 18 | Data: "some data\nmore data", 19 | }) 20 | 21 | // also a complex type, like a map, a struct or a slice 22 | sse.Encode(w, sse.Event{ 23 | Id: "124", 24 | Event: "message", 25 | Data: map[string]interface{}{ 26 | "user": "manu", 27 | "date": time.Now().Unix(), 28 | "content": "hi!", 29 | }, 30 | }) 31 | } 32 | ``` 33 | ``` 34 | event: message 35 | data: some data\\nmore data 36 | 37 | id: 124 38 | event: message 39 | data: {"content":"hi!","date":1431540810,"user":"manu"} 40 | 41 | ``` 42 | 43 | ##Content-Type 44 | 45 | ```go 46 | fmt.Println(sse.ContentType) 47 | ``` 48 | ``` 49 | text/event-stream 50 | ``` 51 | 52 | ##Decoding support 53 | 54 | There is a client-side implementation of SSE coming soon. -------------------------------------------------------------------------------- /vendor/github.com/manucorporat/sse/writer.go: -------------------------------------------------------------------------------- 1 | package sse 2 | 3 | import "io" 4 | 5 | type stringWriter interface { 6 | io.Writer 7 | WriteString(string) (int, error) 8 | } 9 | 10 | type stringWrapper struct { 11 | io.Writer 12 | } 13 | 14 | func (w stringWrapper) WriteString(str string) (int, error) { 15 | return w.Writer.Write([]byte(str)) 16 | } 17 | 18 | func checkWriter(writer io.Writer) stringWriter { 19 | if w, ok := writer.(stringWriter); ok { 20 | return w 21 | } else { 22 | return stringWrapper{writer} 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/mitre/heart/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /vendor/github.com/mitre/heart/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.6 5 | branches: 6 | only: 7 | - master 8 | notifications: 9 | slack: 10 | secure: TdVzF6NIa48X8dUIb0nJ73BlSotF+d+Ov2QGVI0OGM2Y3xKl8jCbNGuePBOtmo2OVmTISdWzBBbd40c6Cy1f924Jh5dVpNJo2PwhFajgcJXGg2hF+3ZniGL20UaVFasrbTK2T/Qf+u++2RQxUY0zrTfdHZSSeKSHvzSumdgyXPIaF6gd1hC++b1W0Tb9owQCx6AJ8wPFyiRtnaFKjD6H1MfyXDq3rjCpi665ejIOBGKWCx0cKZIWry9zyJv4MMweSawUiDgxaCGnxzV655Y9yEV4TzKaurKNVWaIchBj4zKPU7ZJ0TZsNpM46kkS/RrsatUa9AWuol4dV0Fi3VEfblQM8SrsLzTSqqAp28VBTiowqWLdRLXv0mr+l91rNa9CHNiV14S4vbtEq4JhtFleewd2tdUMLKdn0svhXpbwwu/8LthTwKZDi8BaYQaPMFtMvBp0Tyq4zB/kT2Qd/T1nkUnr3RI/+GwpD3RcTzBNdi5/NIX6nG8OeO817S6ZxvaRnondO0+335qG/FmaRozYm+ssO0qGzw9Z5QY0K1m4kMcGEj4b3R46Nf7LeXE4/NnGOkswPzS+tdXYfEu2/2K+vsLualOne8IwNQYp6xQX+OIPpHn9DgoHZWPWHBxYoaNV2LiEXxKW9KHg2bQaLkvTuXLgkqzrlVZtu3zFiGU3csc= 11 | -------------------------------------------------------------------------------- /vendor/github.com/mitre/heart/README.md: -------------------------------------------------------------------------------- 1 | # Go HEART 2 | 3 | This library provides tools for clients to conform to the [HEART Working Group](http://openid.net/wg/heart/) profiles. 4 | Specifically, it provides tools for creating HEART compliant OAuth 2.0 clients, services that utilize HEART compliant 5 | OAuth 2.0 token introspection to allow access as well as HEART compliant OpenID Connect relying parties. 6 | 7 | ## License 8 | Copyright 2016 The MITRE Corporation 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/robfig/cron/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/robfig/cron/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | -------------------------------------------------------------------------------- /vendor/github.com/robfig/cron/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2012 Rob Figueiredo 2 | All Rights Reserved. 3 | 4 | MIT LICENSE 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/robfig/cron/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](http://godoc.org/github.com/robfig/cron?status.png)](http://godoc.org/github.com/robfig/cron) 2 | [![Build Status](https://travis-ci.org/robfig/cron.svg?branch=master)](https://travis-ci.org/robfig/cron) 3 | -------------------------------------------------------------------------------- /vendor/github.com/robfig/cron/constantdelay.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import "time" 4 | 5 | // ConstantDelaySchedule represents a simple recurring duty cycle, e.g. "Every 5 minutes". 6 | // It does not support jobs more frequent than once a second. 7 | type ConstantDelaySchedule struct { 8 | Delay time.Duration 9 | } 10 | 11 | // Every returns a crontab Schedule that activates once every duration. 12 | // Delays of less than a second are not supported (will round up to 1 second). 13 | // Any fields less than a Second are truncated. 14 | func Every(duration time.Duration) ConstantDelaySchedule { 15 | if duration < time.Second { 16 | duration = time.Second 17 | } 18 | return ConstantDelaySchedule{ 19 | Delay: duration - time.Duration(duration.Nanoseconds())%time.Second, 20 | } 21 | } 22 | 23 | // Next returns the next time this should be run. 24 | // This rounds so that the next activation time will be on the second. 25 | func (schedule ConstantDelaySchedule) Next(t time.Time) time.Time { 26 | return t.Add(schedule.Delay - time.Duration(t.Nanosecond())*time.Nanosecond) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENCE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/doc.go: -------------------------------------------------------------------------------- 1 | // Package require implements the same assertions as the `assert` package but 2 | // stops test execution when a test fails. 3 | // 4 | // Example Usage 5 | // 6 | // The following is a complete example using require in a standard test function: 7 | // import ( 8 | // "testing" 9 | // "github.com/stretchr/testify/require" 10 | // ) 11 | // 12 | // func TestSomething(t *testing.T) { 13 | // 14 | // var a string = "Hello" 15 | // var b string = "Hello" 16 | // 17 | // require.Equal(t, a, b, "The two words should be the same.") 18 | // 19 | // } 20 | // 21 | // Assertions 22 | // 23 | // The `require` package have same global functions as in the `assert` package, 24 | // but instead of returning a boolean result they call `t.FailNow()`. 25 | // 26 | // Every assertion function also takes an optional string message as the final argument, 27 | // allowing custom error messages to be appended to the message the assertion method outputs. 28 | package require 29 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/forward_requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.Comment}} 2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { 3 | if !assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { 4 | t.FailNow() 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { 3 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // TestingT is an interface wrapper around *testing.T 4 | type TestingT interface { 5 | Errorf(format string, args ...interface{}) 6 | FailNow() 7 | } 8 | 9 | //go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl 10 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/suite/interfaces.go: -------------------------------------------------------------------------------- 1 | package suite 2 | 3 | import "testing" 4 | 5 | // TestingSuite can store and return the current *testing.T context 6 | // generated by 'go test'. 7 | type TestingSuite interface { 8 | T() *testing.T 9 | SetT(*testing.T) 10 | } 11 | 12 | // SetupAllSuite has a SetupSuite method, which will run before the 13 | // tests in the suite are run. 14 | type SetupAllSuite interface { 15 | SetupSuite() 16 | } 17 | 18 | // SetupTestSuite has a SetupTest method, which will run before each 19 | // test in the suite. 20 | type SetupTestSuite interface { 21 | SetupTest() 22 | } 23 | 24 | // TearDownAllSuite has a TearDownSuite method, which will run after 25 | // all the tests in the suite have been run. 26 | type TearDownAllSuite interface { 27 | TearDownSuite() 28 | } 29 | 30 | // TearDownTestSuite has a TearDownTest method, which will run after 31 | // each test in the suite. 32 | type TearDownTestSuite interface { 33 | TearDownTest() 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - tip 5 | 6 | install: 7 | - export GOPATH="$HOME/gopath" 8 | - mkdir -p "$GOPATH/src/golang.org/x" 9 | - mv "$TRAVIS_BUILD_DIR" "$GOPATH/src/golang.org/x/oauth2" 10 | - go get -v -t -d golang.org/x/oauth2/... 11 | 12 | script: 13 | - go test -v golang.org/x/oauth2/... 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Go 2 | 3 | Go is an open source project. 4 | 5 | It is the work of hundreds of contributors. We appreciate your help! 6 | 7 | 8 | ## Filing issues 9 | 10 | When [filing an issue](https://github.com/golang/oauth2/issues), make sure to answer these five questions: 11 | 12 | 1. What version of Go are you using (`go version`)? 13 | 2. What operating system and processor architecture are you using? 14 | 3. What did you do? 15 | 4. What did you expect to see? 16 | 5. What did you see instead? 17 | 18 | General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. 19 | The gophers there will answer or ask you to file an issue if you've tripped over a bug. 20 | 21 | ## Contributing code 22 | 23 | Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) 24 | before sending patches. 25 | 26 | **We do not accept GitHub pull requests** 27 | (we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). 28 | 29 | Unless otherwise noted, the Go source files are distributed under 30 | the BSD-style license found in the LICENSE file. 31 | 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The oauth2 Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/client_appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | // App Engine hooks. 8 | 9 | package oauth2 10 | 11 | import ( 12 | "net/http" 13 | 14 | "golang.org/x/net/context" 15 | "golang.org/x/oauth2/internal" 16 | "google.golang.org/appengine/urlfetch" 17 | ) 18 | 19 | func init() { 20 | internal.RegisterContextClientFunc(contextClientAppEngine) 21 | } 22 | 23 | func contextClientAppEngine(ctx context.Context) (*http.Client, error) { 24 | return urlfetch.Client(ctx), nil 25 | } 26 | -------------------------------------------------------------------------------- /vendor/gopkg.in/go-playground/validator.v8/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | *.test 26 | *.out 27 | *.txt 28 | cover.html 29 | README.html -------------------------------------------------------------------------------- /vendor/gopkg.in/go-playground/validator.v8/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Dean Karn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/gopkg.in/go-playground/validator.v8/cache.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | import ( 4 | "reflect" 5 | "sync" 6 | ) 7 | 8 | type cachedField struct { 9 | Idx int 10 | Name string 11 | AltName string 12 | CachedTag *cachedTag 13 | } 14 | 15 | type cachedStruct struct { 16 | Name string 17 | fields map[int]cachedField 18 | } 19 | 20 | type structCacheMap struct { 21 | lock sync.RWMutex 22 | m map[reflect.Type]*cachedStruct 23 | } 24 | 25 | func (s *structCacheMap) Get(key reflect.Type) (*cachedStruct, bool) { 26 | s.lock.RLock() 27 | value, ok := s.m[key] 28 | s.lock.RUnlock() 29 | return value, ok 30 | } 31 | 32 | func (s *structCacheMap) Set(key reflect.Type, value *cachedStruct) { 33 | s.lock.Lock() 34 | s.m[key] = value 35 | s.lock.Unlock() 36 | } 37 | 38 | type cachedTag struct { 39 | tag string 40 | isOmitEmpty bool 41 | isNoStructLevel bool 42 | isStructOnly bool 43 | diveTag string 44 | tags []*tagVals 45 | } 46 | 47 | type tagVals struct { 48 | tagVals [][]string 49 | isOrVal bool 50 | isAlias bool 51 | tag string 52 | } 53 | 54 | type tagCacheMap struct { 55 | lock sync.RWMutex 56 | m map[string]*cachedTag 57 | } 58 | 59 | func (s *tagCacheMap) Get(key string) (*cachedTag, bool) { 60 | s.lock.RLock() 61 | value, ok := s.m[key] 62 | s.lock.RUnlock() 63 | 64 | return value, ok 65 | } 66 | 67 | func (s *tagCacheMap) Set(key string, value *cachedTag) { 68 | s.lock.Lock() 69 | s.m[key] = value 70 | s.lock.Unlock() 71 | } 72 | -------------------------------------------------------------------------------- /vendor/gopkg.in/go-playground/validator.v8/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intervention-engine/ie/543417b987f3862b6c197b5b12f6c3735856a67a/vendor/gopkg.in/go-playground/validator.v8/logo.png -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/LICENSE: -------------------------------------------------------------------------------- 1 | mgo - MongoDB driver for Go 2 | 3 | Copyright (c) 2010-2013 - Gustavo Niemeyer 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/Makefile: -------------------------------------------------------------------------------- 1 | startdb: 2 | @testdb/setup.sh start 3 | 4 | stopdb: 5 | @testdb/setup.sh stop 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/README.md: -------------------------------------------------------------------------------- 1 | The MongoDB driver for Go 2 | ------------------------- 3 | 4 | Please go to [http://labix.org/mgo](http://labix.org/mgo) for all project details. 5 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/bson/LICENSE: -------------------------------------------------------------------------------- 1 | BSON library for Go 2 | 3 | Copyright (c) 2010-2012 - Gustavo Niemeyer 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/doc.go: -------------------------------------------------------------------------------- 1 | // Package mgo offers a rich MongoDB driver for Go. 2 | // 3 | // Details about the mgo project (pronounced as "mango") are found 4 | // in its web page: 5 | // 6 | // http://labix.org/mgo 7 | // 8 | // Usage of the driver revolves around the concept of sessions. To 9 | // get started, obtain a session using the Dial function: 10 | // 11 | // session, err := mgo.Dial(url) 12 | // 13 | // This will establish one or more connections with the cluster of 14 | // servers defined by the url parameter. From then on, the cluster 15 | // may be queried with multiple consistency rules (see SetMode) and 16 | // documents retrieved with statements such as: 17 | // 18 | // c := session.DB(database).C(collection) 19 | // err := c.Find(query).One(&result) 20 | // 21 | // New sessions are typically created by calling session.Copy on the 22 | // initial session obtained at dial time. These new sessions will share 23 | // the same cluster information and connection pool, and may be easily 24 | // handed into other methods and functions for organizing logic. 25 | // Every session created must have its Close method called at the end 26 | // of its life time, so its resources may be put back in the pool or 27 | // collected, depending on the case. 28 | // 29 | // For more details, see the documentation for the types and methods. 30 | // 31 | package mgo 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/internal/sasl/sasl.c: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static int mgo_sasl_simple(void *context, int id, const char **result, unsigned int *len) 9 | { 10 | if (!result) { 11 | return SASL_BADPARAM; 12 | } 13 | switch (id) { 14 | case SASL_CB_USER: 15 | *result = (char *)context; 16 | break; 17 | case SASL_CB_AUTHNAME: 18 | *result = (char *)context; 19 | break; 20 | case SASL_CB_LANGUAGE: 21 | *result = NULL; 22 | break; 23 | default: 24 | return SASL_BADPARAM; 25 | } 26 | if (len) { 27 | *len = *result ? strlen(*result) : 0; 28 | } 29 | return SASL_OK; 30 | } 31 | 32 | typedef int (*callback)(void); 33 | 34 | static int mgo_sasl_secret(sasl_conn_t *conn, void *context, int id, sasl_secret_t **result) 35 | { 36 | if (!conn || !result || id != SASL_CB_PASS) { 37 | return SASL_BADPARAM; 38 | } 39 | *result = (sasl_secret_t *)context; 40 | return SASL_OK; 41 | } 42 | 43 | sasl_callback_t *mgo_sasl_callbacks(const char *username, const char *password) 44 | { 45 | sasl_callback_t *cb = malloc(4 * sizeof(sasl_callback_t)); 46 | int n = 0; 47 | 48 | size_t len = strlen(password); 49 | sasl_secret_t *secret = (sasl_secret_t*)malloc(sizeof(sasl_secret_t) + len); 50 | if (!secret) { 51 | free(cb); 52 | return NULL; 53 | } 54 | strcpy((char *)secret->data, password); 55 | secret->len = len; 56 | 57 | cb[n].id = SASL_CB_PASS; 58 | cb[n].proc = (callback)&mgo_sasl_secret; 59 | cb[n].context = secret; 60 | n++; 61 | 62 | cb[n].id = SASL_CB_USER; 63 | cb[n].proc = (callback)&mgo_sasl_simple; 64 | cb[n].context = (char*)username; 65 | n++; 66 | 67 | cb[n].id = SASL_CB_AUTHNAME; 68 | cb[n].proc = (callback)&mgo_sasl_simple; 69 | cb[n].context = (char*)username; 70 | n++; 71 | 72 | cb[n].id = SASL_CB_LIST_END; 73 | cb[n].proc = NULL; 74 | cb[n].context = NULL; 75 | 76 | return cb; 77 | } 78 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "sspi_windows.h" 4 | 5 | SECURITY_STATUS SEC_ENTRY sspi_acquire_credentials_handle(CredHandle* cred_handle, char* username, char* password, char* domain); 6 | int sspi_step(CredHandle* cred_handle, int has_context, CtxtHandle* context, PVOID* buffer, ULONG* buffer_length, char* target); 7 | int sspi_send_client_authz_id(CtxtHandle* context, PVOID* buffer, ULONG* buffer_length, char* user_plus_realm); 8 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/raceoff.go: -------------------------------------------------------------------------------- 1 | // +build !race 2 | 3 | package mgo 4 | 5 | const raceDetector = false 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/raceon.go: -------------------------------------------------------------------------------- 1 | // +build race 2 | 3 | package mgo 4 | 5 | const raceDetector = true 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/saslimpl.go: -------------------------------------------------------------------------------- 1 | //+build sasl 2 | 3 | package mgo 4 | 5 | import ( 6 | "gopkg.in/mgo.v2/internal/sasl" 7 | ) 8 | 9 | func saslNew(cred Credential, host string) (saslStepper, error) { 10 | return sasl.New(cred.Username, cred.Password, cred.Mechanism, cred.Service, host) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/saslstub.go: -------------------------------------------------------------------------------- 1 | //+build !sasl 2 | 3 | package mgo 4 | 5 | import ( 6 | "fmt" 7 | ) 8 | 9 | func saslNew(cred Credential, host string) (saslStepper, error) { 10 | return nil, fmt.Errorf("SASL support not enabled during build (-tags sasl)") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/.gitcookies.sh.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intervention-engine/ie/543417b987f3862b6c197b5b12f6c3735856a67a/vendor/gopkg.in/square/go-jose.v1/.gitcookies.sh.enc -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .*.swp 3 | *.out 4 | *.test 5 | *.pem 6 | *.cov 7 | jose-util/jose-util 8 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | sudo: false 4 | 5 | matrix: 6 | fast_finish: true 7 | allow_failures: 8 | - go: tip 9 | 10 | go: 11 | - 1.3 12 | - 1.4 13 | - 1.5 14 | - 1.6 15 | - tip 16 | 17 | go_import_path: gopkg.in/square/go-jose.v1 18 | 19 | before_script: 20 | - export PATH=$HOME/.local/bin:$PATH 21 | 22 | before_install: 23 | # Install encrypted gitcookies to get around bandwidth-limits 24 | # that is causing Travis-CI builds to fail. For more info, see 25 | # https://github.com/golang/go/issues/12933 26 | - openssl aes-256-cbc -K $encrypted_1528c3c2cafd_key -iv $encrypted_1528c3c2cafd_iv -in .gitcookies.sh.enc -out .gitcookies.sh -d || true 27 | - bash .gitcookies.sh || true 28 | - go get github.com/wadey/gocovmerge 29 | - go get github.com/mattn/goveralls 30 | - go get golang.org/x/tools/cmd/cover || true 31 | - go get code.google.com/p/go.tools/cmd/cover || true 32 | - pip install cram --user `whoami` 33 | 34 | script: 35 | - go test . -v -covermode=count -coverprofile=profile.cov 36 | - go test . -tags std_json -v -covermode=count -coverprofile=profile-std-json.cov 37 | - go test ./cipher -v -covermode=count -coverprofile=cipher/profile.cov 38 | - go test ./json -v # no coverage for forked encoding/json package 39 | - cd jose-util && go build && PATH=$PWD:$PATH cram -v jose-util.t 40 | - cd .. 41 | 42 | after_success: 43 | - gocovmerge *.cov */*.cov > merged.coverprofile 44 | - $HOME/gopath/bin/goveralls -coverprofile merged.coverprofile -service=travis-ci 45 | 46 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/BUG-BOUNTY.md: -------------------------------------------------------------------------------- 1 | Serious about security 2 | ====================== 3 | 4 | Square recognizes the important contributions the security research community 5 | can make. We therefore encourage reporting security issues with the code 6 | contained in this repository. 7 | 8 | If you believe you have discovered a security vulnerability, please follow the 9 | guidelines at . 10 | 11 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | If you would like to contribute code to go-jose you can do so through GitHub by 4 | forking the repository and sending a pull request. 5 | 6 | When submitting code, please make every effort to follow existing conventions 7 | and style in order to keep the code as readable as possible. Please also make 8 | sure all tests pass by running `go test`, and format your code with `go fmt`. 9 | We also recommend using `golint` and `errcheck`. 10 | 11 | Before your code can be accepted into the project you must also sign the 12 | [Individual Contributor License Agreement][1]. 13 | 14 | [1]: https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1 15 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf.go: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2014 Square Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package josecipher 18 | 19 | import ( 20 | "crypto" 21 | "encoding/binary" 22 | "hash" 23 | "io" 24 | ) 25 | 26 | type concatKDF struct { 27 | z, info []byte 28 | i uint32 29 | cache []byte 30 | hasher hash.Hash 31 | } 32 | 33 | // NewConcatKDF builds a KDF reader based on the given inputs. 34 | func NewConcatKDF(hash crypto.Hash, z, algID, ptyUInfo, ptyVInfo, supPubInfo, supPrivInfo []byte) io.Reader { 35 | buffer := make([]byte, len(algID)+len(ptyUInfo)+len(ptyVInfo)+len(supPubInfo)+len(supPrivInfo)) 36 | n := 0 37 | n += copy(buffer, algID) 38 | n += copy(buffer[n:], ptyUInfo) 39 | n += copy(buffer[n:], ptyVInfo) 40 | n += copy(buffer[n:], supPubInfo) 41 | copy(buffer[n:], supPrivInfo) 42 | 43 | hasher := hash.New() 44 | 45 | return &concatKDF{ 46 | z: z, 47 | info: buffer, 48 | hasher: hasher, 49 | cache: []byte{}, 50 | i: 1, 51 | } 52 | } 53 | 54 | func (ctx *concatKDF) Read(out []byte) (int, error) { 55 | copied := copy(out, ctx.cache) 56 | ctx.cache = ctx.cache[copied:] 57 | 58 | for copied < len(out) { 59 | ctx.hasher.Reset() 60 | 61 | // Write on a hash.Hash never fails 62 | _ = binary.Write(ctx.hasher, binary.BigEndian, ctx.i) 63 | _, _ = ctx.hasher.Write(ctx.z) 64 | _, _ = ctx.hasher.Write(ctx.info) 65 | 66 | hash := ctx.hasher.Sum(nil) 67 | chunkCopied := copy(out[copied:], hash) 68 | copied += chunkCopied 69 | ctx.cache = hash[chunkCopied:] 70 | 71 | ctx.i++ 72 | } 73 | 74 | return copied, nil 75 | } 76 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es.go: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2014 Square Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package josecipher 18 | 19 | import ( 20 | "crypto" 21 | "crypto/ecdsa" 22 | "encoding/binary" 23 | ) 24 | 25 | // DeriveECDHES derives a shared encryption key using ECDH/ConcatKDF as described in JWE/JWA. 26 | func DeriveECDHES(alg string, apuData, apvData []byte, priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey, size int) []byte { 27 | // algId, partyUInfo, partyVInfo inputs must be prefixed with the length 28 | algID := lengthPrefixed([]byte(alg)) 29 | ptyUInfo := lengthPrefixed(apuData) 30 | ptyVInfo := lengthPrefixed(apvData) 31 | 32 | // suppPubInfo is the encoded length of the output size in bits 33 | supPubInfo := make([]byte, 4) 34 | binary.BigEndian.PutUint32(supPubInfo, uint32(size)*8) 35 | 36 | z, _ := priv.PublicKey.Curve.ScalarMult(pub.X, pub.Y, priv.D.Bytes()) 37 | reader := NewConcatKDF(crypto.SHA256, z.Bytes(), algID, ptyUInfo, ptyVInfo, supPubInfo, []byte{}) 38 | 39 | key := make([]byte, size) 40 | 41 | // Read on the KDF will never fail 42 | _, _ = reader.Read(key) 43 | return key 44 | } 45 | 46 | func lengthPrefixed(data []byte) []byte { 47 | out := make([]byte, len(data)+4) 48 | binary.BigEndian.PutUint32(out, uint32(len(data))) 49 | copy(out[4:], data) 50 | return out 51 | } 52 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/doc.go: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2014 Square Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | 19 | Package jose aims to provide an implementation of the Javascript Object Signing 20 | and Encryption set of standards. For the moment, it mainly focuses on 21 | encryption and signing based on the JSON Web Encryption and JSON Web Signature 22 | standards. The library supports both the compact and full serialization 23 | formats, and has optional support for multiple recipients. 24 | 25 | */ 26 | package jose 27 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/json/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/json/README.md: -------------------------------------------------------------------------------- 1 | # Safe JSON 2 | 3 | This repository contains a fork of the `encoding/json` package from Go 1.6. 4 | 5 | The following changes were made: 6 | 7 | * Object deserialization uses case-sensitive member name matching instead of 8 | [case-insensitive matching](https://www.ietf.org/mail-archive/web/json/current/msg03763.html). 9 | This is to avoid differences in the interpretation of JOSE messages between 10 | go-jose and libraries written in other languages. 11 | * When deserializing a JSON object, we check for duplicate keys and reject the 12 | input whenever we detect a duplicate. Rather than trying to work with malformed 13 | data, we prefer to reject it right away. 14 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/json/tags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package json 6 | 7 | import ( 8 | "strings" 9 | ) 10 | 11 | // tagOptions is the string following a comma in a struct field's "json" 12 | // tag, or the empty string. It does not include the leading comma. 13 | type tagOptions string 14 | 15 | // parseTag splits a struct field's json tag into its name and 16 | // comma-separated options. 17 | func parseTag(tag string) (string, tagOptions) { 18 | if idx := strings.Index(tag, ","); idx != -1 { 19 | return tag[:idx], tagOptions(tag[idx+1:]) 20 | } 21 | return tag, tagOptions("") 22 | } 23 | 24 | // Contains reports whether a comma-separated list of options 25 | // contains a particular substr flag. substr must be surrounded by a 26 | // string boundary or commas. 27 | func (o tagOptions) Contains(optionName string) bool { 28 | if len(o) == 0 { 29 | return false 30 | } 31 | s := string(o) 32 | for s != "" { 33 | var next string 34 | i := strings.Index(s, ",") 35 | if i >= 0 { 36 | s, next = s[:i], s[i+1:] 37 | } 38 | if s == optionName { 39 | return true 40 | } 41 | s = next 42 | } 43 | return false 44 | } 45 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/json_fork.go: -------------------------------------------------------------------------------- 1 | // +build !std_json 2 | 3 | /*- 4 | * Copyright 2014 Square Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package jose 20 | 21 | import ( 22 | "gopkg.in/square/go-jose.v1/json" 23 | ) 24 | 25 | func MarshalJSON(v interface{}) ([]byte, error) { 26 | return json.Marshal(v) 27 | } 28 | 29 | func UnmarshalJSON(data []byte, v interface{}) error { 30 | return json.Unmarshal(data, v) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/json_std.go: -------------------------------------------------------------------------------- 1 | // +build std_json 2 | 3 | /*- 4 | * Copyright 2014 Square Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package jose 20 | 21 | import ( 22 | "encoding/json" 23 | ) 24 | 25 | func MarshalJSON(v interface{}) ([]byte, error) { 26 | return json.Marshal(v) 27 | } 28 | 29 | func UnmarshalJSON(data []byte, v interface{}) error { 30 | return json.Unmarshal(data, v) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/square/go-jose.v1/utils.go: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2014 Square Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package jose 18 | 19 | import ( 20 | "crypto/x509" 21 | "encoding/pem" 22 | "fmt" 23 | ) 24 | 25 | // LoadPublicKey loads a public key from PEM/DER-encoded data. 26 | func LoadPublicKey(data []byte) (interface{}, error) { 27 | input := data 28 | 29 | block, _ := pem.Decode(data) 30 | if block != nil { 31 | input = block.Bytes 32 | } 33 | 34 | // Try to load SubjectPublicKeyInfo 35 | pub, err0 := x509.ParsePKIXPublicKey(input) 36 | if err0 == nil { 37 | return pub, nil 38 | } 39 | 40 | cert, err1 := x509.ParseCertificate(input) 41 | if err1 == nil { 42 | return cert.PublicKey, nil 43 | } 44 | 45 | return nil, fmt.Errorf("square/go-jose: parse error, got '%s' and '%s'", err0, err1) 46 | } 47 | 48 | // LoadPrivateKey loads a private key from PEM/DER-encoded data. 49 | func LoadPrivateKey(data []byte) (interface{}, error) { 50 | input := data 51 | 52 | block, _ := pem.Decode(data) 53 | if block != nil { 54 | input = block.Bytes 55 | } 56 | 57 | var priv interface{} 58 | priv, err0 := x509.ParsePKCS1PrivateKey(input) 59 | if err0 == nil { 60 | return priv, nil 61 | } 62 | 63 | priv, err1 := x509.ParsePKCS8PrivateKey(input) 64 | if err1 == nil { 65 | return priv, nil 66 | } 67 | 68 | priv, err2 := x509.ParseECPrivateKey(input) 69 | if err2 == nil { 70 | return priv, nil 71 | } 72 | 73 | return nil, fmt.Errorf("square/go-jose: parse error, got '%s', '%s' and '%s'", err0, err1, err2) 74 | } 75 | -------------------------------------------------------------------------------- /vendor/gopkg.in/tomb.v2/LICENSE: -------------------------------------------------------------------------------- 1 | tomb - support for clean goroutine termination in Go. 2 | 3 | Copyright (c) 2010-2011 - Gustavo Niemeyer 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /vendor/gopkg.in/tomb.v2/README.md: -------------------------------------------------------------------------------- 1 | Installation and usage 2 | ---------------------- 3 | 4 | See [gopkg.in/tomb.v2](https://gopkg.in/tomb.v2) for documentation and usage details. 5 | -------------------------------------------------------------------------------- /web/care_team_handlers.go: -------------------------------------------------------------------------------- 1 | package web 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gin-gonic/gin" 7 | "github.com/intervention-engine/ie" 8 | ) 9 | 10 | // ListAllCareTeams List all care teams 11 | func ListAllCareTeams(ctx *gin.Context) { 12 | s := getCareTeamService(ctx) 13 | cc, err := s.CareTeams() 14 | 15 | Render(ctx, gin.H{"care_teams": cc}, err) 16 | } 17 | 18 | // GetCareTeam Get a care team with given id. 19 | func GetCareTeam(ctx *gin.Context) { 20 | s := getCareTeamService(ctx) 21 | 22 | id := ctx.Param("id") 23 | ct, err := s.CareTeam(id) 24 | 25 | Render(ctx, gin.H{"care_team": ct}, err) 26 | } 27 | 28 | // CreateCareTeam Create a care team 29 | func CreateCareTeam(ctx *gin.Context) { 30 | s := getCareTeamService(ctx) 31 | 32 | ct := &ie.CareTeam{} 33 | 34 | if bindFormData(ctx, ct) { 35 | err := s.CreateCareTeam(ct) 36 | Render(ctx, gin.H{"care_team": ct}, err) 37 | } 38 | } 39 | 40 | // UpdateCareTeam Update a care team with given id 41 | func UpdateCareTeam(ctx *gin.Context) { 42 | s := getCareTeamService(ctx) 43 | 44 | id := ctx.Param("id") 45 | ct, err := s.CareTeam(id) 46 | 47 | if err != nil { 48 | status := ErrCode(err) 49 | ctx.AbortWithError(status, err) 50 | return 51 | } 52 | 53 | if bindFormData(ctx, ct) { 54 | err = s.UpdateCareTeam(ct) 55 | Render(ctx, gin.H{"care_team": ct}, err) 56 | } 57 | } 58 | 59 | // DeleteCareTeam Delete a care team 60 | func DeleteCareTeam(ctx *gin.Context) { 61 | s := getCareTeamService(ctx) 62 | 63 | id := ctx.Param("id") 64 | err := s.DeleteCareTeam(id) 65 | 66 | Render(ctx, nil, err) 67 | } 68 | 69 | func getCareTeamService(ctx *gin.Context) ie.CareTeamService { 70 | svc := ctx.MustGet("careTeamService") 71 | return svc.(ie.CareTeamService) 72 | } 73 | 74 | func bindFormData(ctx *gin.Context, ct *ie.CareTeam) bool { 75 | var form ie.CareTeam 76 | 77 | if ctx.Bind(&form) != nil { 78 | ct.Name = form.Name 79 | ct.Leader = form.Leader 80 | return true 81 | } 82 | ctx.AbortWithError(http.StatusBadRequest, nil) 83 | return false 84 | } 85 | -------------------------------------------------------------------------------- /web/patient_handlers.go: -------------------------------------------------------------------------------- 1 | package web 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | "github.com/intervention-engine/ie" 6 | ) 7 | 8 | // ListAllPatients List all patients 9 | func ListAllPatients(ctx *gin.Context) { 10 | s := getPatientService(ctx) 11 | pp, err := s.Patients() 12 | Render(ctx, gin.H{"patients": pp}, err) 13 | } 14 | 15 | // ListAllCareTeamPatients that belong to a given care team 16 | func ListAllCareTeamPatients(ctx *gin.Context) { 17 | id := ctx.Param("care_team_id") 18 | pp, err := patientsForCareTeam(ctx, id) 19 | Render(ctx, gin.H{"patients": pp}, err) 20 | } 21 | 22 | // AddPatientToCareTeam create a membership for a patient 23 | func AddPatientToCareTeam(ctx *gin.Context) { 24 | ct := ctx.Param("care_team_id") 25 | p := ctx.Param("id") 26 | mem := ie.Membership{CareTeamID: ct, PatientID: p} 27 | err := getMembershipService(ctx).CreateMembership(mem) 28 | Render(ctx, gin.H{"membership": mem}, err) 29 | } 30 | 31 | // GetPatient Get a patient with given id. 32 | func GetPatient(ctx *gin.Context) { 33 | s := getPatientService(ctx) 34 | id := ctx.Param("id") 35 | p, err := s.Patient(id) 36 | Render(ctx, gin.H{"patient": p}, err) 37 | } 38 | 39 | func getPatientService(ctx *gin.Context) ie.PatientService { 40 | svc := ctx.MustGet("patientService") 41 | return svc.(ie.PatientService) 42 | } 43 | 44 | func getMembershipService(ctx *gin.Context) ie.MembershipService { 45 | svc := ctx.MustGet("membershipService") 46 | return svc.(ie.MembershipService) 47 | } 48 | 49 | // patientsForCareTeam Utility Function to get Patients that belong to a care team 50 | func patientsForCareTeam(ctx *gin.Context, id string) ([]ie.Patient, error) { 51 | 52 | mems, err := getMembershipService(ctx).PatientMemberships(id) 53 | 54 | if err != nil { 55 | return nil, err 56 | } 57 | 58 | ids := make([]string, len(mems)) 59 | 60 | for i, mem := range mems { 61 | ids[i] = mem.PatientID 62 | } 63 | 64 | pp, err := getPatientService(ctx).PatientsByID(ids) 65 | 66 | if err != nil { 67 | return nil, err 68 | } 69 | 70 | return pp, nil 71 | } 72 | -------------------------------------------------------------------------------- /web/utils.go: -------------------------------------------------------------------------------- 1 | package web 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | // Render handles errors and renders appropriate content 10 | func Render(ctx *gin.Context, json map[string]interface{}, err error) { 11 | if err != nil { 12 | ctx.AbortWithError(ErrCode(err), err) 13 | } else { 14 | if json != nil { 15 | ctx.JSON(http.StatusOK, json) 16 | } else { 17 | ctx.Status(http.StatusNoContent) 18 | } 19 | 20 | } 21 | } 22 | 23 | // ErrCode Matches the service error to the corresponding HTTP Error Code 24 | func ErrCode(err error) int { 25 | if err.Error() == "not found" { 26 | return http.StatusNotFound 27 | } else if err.Error() == "bad id" { 28 | return http.StatusBadRequest 29 | } 30 | 31 | return http.StatusInternalServerError 32 | } 33 | --------------------------------------------------------------------------------