Documentation ¶
Overview ¶
The MIT License (MIT)
Copyright (c) 2013 Greivin López ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The MIT License (MIT)
Copyright (c) 2013 Greivin López ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func Consume(consumer Consumer, w http.ResponseWriter, r *http.Request, value interface{}) error
- func Create(view ViewLayer, model DatabasePersistor, w http.ResponseWriter, ...)
- func Delete(view ViewLayer, model DatabasePersistor, cache MemoryCacher, ...)
- func List(view ViewLayer, model DatabasePersistor, w http.ResponseWriter, ...)
- func NotAllowed(producer Producer, w http.ResponseWriter, r *http.Request)
- func NotFound(producer Producer, w http.ResponseWriter, r *http.Request)
- func Produce(producer Producer, w http.ResponseWriter, r *http.Request, status int, ...)
- func Read(view ViewLayer, model DatabasePersistor, cache MemoryCacher, ...)
- func ServiceResponse(producer Producer, w http.ResponseWriter, r *http.Request, httpStatus int, ...)
- func Update(view ViewLayer, model DatabasePersistor, cache MemoryCacher, ...)
- type Consumer
- type DatabasePersistor
- type MemoryCacher
- type Producer
- type SimpleMessage
- type ViewLayer
Constants ¶
const ( MIME_XML = "application/xml" MIME_JSON = "application/json" HEADER_Allow = "Allow" HEADER_Accept = "Accept" HEADER_Origin = "Origin" HEADER_ContentType = "Content-Type" HEADER_LastModified = "Last-Modified" HEADER_AcceptEncoding = "Accept-Encoding" HEADER_ContentEncoding = "Content-Encoding" HEADER_AccessControlExposeHeaders = "Access-Control-Expose-Headers" HEADER_AccessControlRequestMethod = "Access-Control-Request-Method" HEADER_AccessControlRequestHeaders = "Access-Control-Request-Headers" HEADER_AccessControlAllowMethods = "Access-Control-Allow-Methods" HEADER_AccessControlAllowOrigin = "Access-Control-Allow-Origin" HEADER_AccessControlAllowCredentials = "Access-Control-Allow-Credentials" HEADER_AccessControlAllowHeaders = "Access-Control-Allow-Headers" HEADER_XRateLimitLimit = "X-Rate-Limit-Limit" HEADER_XRateLimitRemaining = "X-Rate-Limit-Remaining" )
Variables ¶
var ErrNotFound = errors.New("not found")
Functions ¶
func Create ¶
func Create(view ViewLayer, model DatabasePersistor, w http.ResponseWriter, r *http.Request)
Saves a model to the underlying storage. Internally it calls the Create method of the given model. The model is constructed from the JSON body of the given request. Writes to the http writer according to what happens with the model following the REST architectural style.
func Delete ¶
func Delete(view ViewLayer, model DatabasePersistor, cache MemoryCacher, w http.ResponseWriter, r *http.Request)
Deletes the model in the underlying storage. Internally it calls the Read method of the given model which assumes it knows it's id. If the model is created successfully then it calls the Delete method. Writes to the http writer according to what happens with the model following the REST architectural style.
func List ¶
func List(view ViewLayer, model DatabasePersistor, w http.ResponseWriter, r *http.Request)
Returns the list of elements associated to the givem model in the underlying storage. Writes to the http writer accordingly following the REST architectural style.
func NotAllowed ¶
func NotAllowed(producer Producer, w http.ResponseWriter, r *http.Request)
NotAllowed handler will response with a "405 Method Not Allowed" response It is a convenience handler to route all not allowed services
func NotFound ¶
func NotFound(producer Producer, w http.ResponseWriter, r *http.Request)
NotFound handler will respond with a "404 Not Found" response
func Read ¶
func Read(view ViewLayer, model DatabasePersistor, cache MemoryCacher, w http.ResponseWriter, r *http.Request)
Reads the model from underlying storage. Internally it calls the Read method of the given model which assumes it knows it's id. Writes to the http writer according to what happens with the model following the REST architectural style.
func ServiceResponse ¶
func ServiceResponse(producer Producer, w http.ResponseWriter, r *http.Request, httpStatus int, message string)
ServiceResponse is a convenience function to create an http response encoded as JSON with a simple message
func Update ¶
func Update(view ViewLayer, model DatabasePersistor, cache MemoryCacher, w http.ResponseWriter, r *http.Request)
Updates the given model in the underlying storage Internally it calls the Update method of the given model. The model is constructed from the JSON body of the given request. Writes to the http writer according to what happens with the model following the REST architectural style.
Types ¶
type Consumer ¶
Consumer is intended to be a decoder of HTTP requests that uses a particular MIME type to decode the intended object into a value.
type DatabasePersistor ¶
type DatabasePersistor interface { Create() (err error) Read(cache MemoryCacher) (err error) Update(cache MemoryCacher) (err error) Delete(cache MemoryCacher) (err error) List() (result interface{}, err error) }
DatabasePersistor represents any abstraction that can follow the CRUD operations. Create, Read, Update and Delete are the four basic operations of persistent storage.
type MemoryCacher ¶
type MemoryCacher interface { Set(key interface{}, value interface{}) error Get(key interface{}, value interface{}) error Delete(key interface{}) error }
MemoryCacher represents an abstraction of any memory caching system used to speed up data driven systems by caching data in RAM instead of HD. Memory caching system examples: - Memcached: http://www.memcached.org - Redis: http://redis.io/ More info here: Caching: http://en.wikipedia.org/wiki/Cache_(computing)
type Producer ¶
type Producer interface { MimeType() string Out(w http.ResponseWriter, statusCode int, value interface{}) }
Producer is intended to be an encoder that writes a value to http writers for a particular MIME type.
type SimpleMessage ¶
SimpleMessage represents an HTTP simple response with an HTTP status code and a response message
Directories ¶
Path | Synopsis |
---|---|
This work uses "Redigo" package by Gary Burd: https://github.com/garyburd/redigo -------------- Redigo License -------------- Copyright 2012 Gary Burd Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License.
|
This work uses "Redigo" package by Gary Burd: https://github.com/garyburd/redigo -------------- Redigo License -------------- Copyright 2012 Gary Burd Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. |
The MIT License (MIT) Copyright (c) 2014 Greivin López Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
The MIT License (MIT) Copyright (c) 2014 Greivin López Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
examples
|
|
soccer
The MIT License (MIT) Copyright (c) 2014 Greivin López Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
The MIT License (MIT) Copyright (c) 2014 Greivin López Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
soccer/database
The MIT License (MIT) Copyright (c) 2014 Greivin López Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
The MIT License (MIT) Copyright (c) 2014 Greivin López Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |