github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/apiv3/doc.go (about) 1 /* 2 The REST API V2 has a series of central types that are useful to understand when 3 adding new endpoints or increasing its functionality. 4 5 Model 6 7 Models are structs that represent the object returned by the API. A model 8 is an interface with two methods, BuildFromService and ToService that 9 define how to transform to and from an API model. 10 11 ServiceContext 12 13 ServiceContext is a very large interface that defines interaction with the backing 14 database and service layer. It has two main sets of implementations: one that 15 communicate with the database and one that mocks the same functionality. Development 16 does not require the creation of new ServiceContext's, only addition to extant ones. 17 18 RequestHandler 19 20 RequestHandler is an interface which defines how to process an HTTP request 21 for an API resource. RequestHandlers implement methods for fetching a new copy 22 of the RequestHandler, ParseAndValidate the request body and how to execute 23 the bulk of the request against the database. 24 25 MethodHandler 26 27 MethodHandler is an struct that contains all of the data necessary for 28 completing an API request. It contains an Authenticator to handle access control. 29 Authenticator is an interface type with many implementations that permit user's 30 access based on different sets of criteria. MethodHandlers also contain functions 31 for attaching data to a request and a RequestHandler to execute the request. 32 33 RouteManager 34 35 RouteManagers are structs that define all of the functionality of a particular 36 API route, including definitions of each of the methods it implements and the 37 path used to access it. 38 39 PaginationExecutor 40 41 PaginationExecutor is a type that handles gathering necessary information for 42 paginating and handles executing the necessary parts of the API request. The 43 PaginationExecutor type is an implemention of the RequestHandler so that writing paginated 44 endpoints does not necessarily require rewriting these methods; However, any of 45 these methods may be overwritten to provide additional flexibility and funcitonality. 46 47 PaginatorFunc 48 49 PaginatorFunc is a function type that defines how to perform pagination over a 50 specific resource. It is the only type that is required to be implemented when 51 adding paginated API resources. 52 53 */ 54 package apiv3