An open API service indexing awesome lists of open source software.

https://github.com/apsdehal/lein-clj-service

Lein template for a clojure service.
https://github.com/apsdehal/lein-clj-service

Last synced: 4 months ago
JSON representation

Lein template for a clojure service.

Awesome Lists containing this project

README

          

# Lein Clojure Service

Leiningen template for a clojure based HTTP service. Following libraries are preincluded:

- [Ring](https://github.com/mmcgrana/ring)
- [Compojure](https://github.com/weavejester/compojure)
- [Compojure-API](https://github.com/metosin/compojure-api)
- [Ring-Swagger](https://github.com/metosin/ring-swagger)

## Usage

To create a new service, add the following to your lein `~/.lein/profiles.clj`

```clj
{:user {:plugins [[clj-service/lein-template "LATEST"]]}}
```

After this you can create the service with:

```
lein new clj-service
```

This will prompt for base path and port number of the service. Base path is where you main code will lie. For e.g passing `com/sdslabs` with name `lens` will create all code in `src/com/sdslabs/lens`.

Example:

```
lein new clj-service lens
```

Every service should have a unique port locally so that you can run more than one service locally.

## Service

Your service consists of three functions:

__initialize!__: Sets up the global state.

__Handler function__: Takes the request

__destroy__: Destroys global state.

## License

Distributed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)