<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>
-
URL
<The URL Structure (path only, no root url)>
-
Method:
| package object mail { | |
| implicit def stringToSeq(single: String): Seq[String] = Seq(single) | |
| implicit def liftToOption[T](t: T): Option[T] = Some(t) | |
| sealed abstract class MailType | |
| case object Plain extends MailType | |
| case object Rich extends MailType | |
| case object MultiPart extends MailType |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here."For comprehension" is a another syntaxe to use map, flatMap and withFilter (or filter) methods.
yield keyword is used to aggregate values in the resulting structure.
This composition can be used on any type implementing this methods, like List, Option, Try, Future...
| import java.util.concurrent.Callable; | |
| import java.util.concurrent.ExecutorService; | |
| import java.util.concurrent.Future; | |
| import java.util.concurrent.LinkedBlockingQueue; | |
| import java.util.concurrent.ThreadPoolExecutor; | |
| import java.util.concurrent.TimeUnit; | |
| public class FuturesA { | |
| public static void run() throws Exception { |
| import java.io._ | |
| @SerialVersionUID(15L) | |
| class Animal(name: String, age: Int) extends Serializable { | |
| override def toString = s"Animal($name, $age)" | |
| } | |
| case class Person(name: String) | |
| // or fork := true in sbt |
| import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper} | |
| import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper | |
| import com.fasterxml.jackson.module.scala.DefaultScalaModule | |
| object JsonUtil { | |
| val mapper = new ObjectMapper with ScalaObjectMapper | |
| mapper.registerModule(DefaultScalaModule) | |
| mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) | |
| def toJson(value: Map[Symbol, Any]): String = { |
https://github.com/djvirgen/virgen-acl Simple and elegant, create your own checks. No middleware?
https://github.com/OptimalBits/node_acl Use as middleware, create your own roles and access. Great choice.
https://github.com/tschaub/authorized Similar to connect roles... but a bit more robust? you can create roles and action, and associate many roles with that action
| import java.io.IOException; | |
| import java.nio.charset.StandardCharsets; | |
| import java.nio.file.Files; | |
| import java.util.Arrays; | |
| import java.util.Iterator; | |
| import java.util.Properties; | |
| import org.I0Itec.zkclient.ZkClient; | |
| import org.apache.kafka.clients.consumer.ConsumerRecord; | |
| import org.apache.kafka.clients.consumer.ConsumerRecords; | |
| import org.apache.kafka.clients.consumer.KafkaConsumer; |