Skip to content

Commit

Permalink
Tidy up documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sideshow committed Jan 30, 2016
1 parent ee0f0cc commit 8a1b9b9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ APNS/2 is an (Experimental) go package designed for simple, flexible and fast Ap
[![Build Status](https://travis-ci.org/sideshow/apns2.svg?branch=master)](https://travis-ci.org/sideshow/apns2) [![Coverage Status](https://coveralls.io/repos/sideshow/apns2/badge.svg?branch=master&service=github)](https://coveralls.io/github/sideshow/apns2?branch=master) [![GoDoc](https://godoc.org/github.com/sideshow/apns2?status.svg)](https://godoc.org/github.com/sideshow/apns2)

## Features
- Uses new Apple APNS HTTP/2 connection
- Uses new Apple APNs HTTP/2 connection
- Works with older versions of go (1.4.x) not just 1.6
- Supports persistent connections to APNS
- Supports persistent connections to APNs
- Fast, modular & easy to use
- Tested and working in APNs production environment

Expand Down Expand Up @@ -80,7 +80,7 @@ if err != nil {
return
}
if res.Sent() {
log.Println("Successfully sent", res.ApnsID())
log.Println("APNs ID:", res.ApnsID())
}
```

Expand Down
2 changes: 1 addition & 1 deletion _example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ func main() {
return
}

log.Println("APNS Sent:", res.ApnsID)
log.Println("APNs ID:", res.ApnsID)
}
26 changes: 13 additions & 13 deletions certificate/certificate.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package certificate contains functions to load an Apple APNs .p12
// or .pem certificate from either an in memory byte array or a local file.
// Package certificate contains functions to load an Apple APNs PKCS#12
// or PEM certificate from either an in memory byte array or a local file.
package certificate

import (
Expand All @@ -23,7 +23,7 @@ var (
ErrNoCertificate = errors.New("no certificate")
)

// FromP12File loads a `.p12` certificate from a local file and returns a
// FromP12File loads a PKCS#12 certificate from a local file and returns a
// tls.Certificate.
//
// Use "" as the password argument if the pem certificate is not password
Expand All @@ -36,10 +36,10 @@ func FromP12File(filename string, password string) (tls.Certificate, error) {
return FromP12Bytes(p12bytes, password)
}

// FromP12Bytes loads a `.p12` certificate from an in memory byte array and
// FromP12Bytes loads a PKCS#12 certificate from an in memory byte array and
// returns a tls.Certificate.
//
// Use "" as the password argument if the pem certificate is not password
// Use "" as the password argument if the PKCS#12 certificate is not password
// protected.
func FromP12Bytes(bytes []byte, password string) (tls.Certificate, error) {
key, cert, err := pkcs12.Decode(bytes, password)
Expand All @@ -53,13 +53,13 @@ func FromP12Bytes(bytes []byte, password string) (tls.Certificate, error) {
}, nil
}

// FromPemFile loads a `.pem` certificate from a local file and returns a
// FromPemFile loads a PEM certificate from a local file and returns a
// tls.Certificate. This function is similar to the crypto/tls LoadX509KeyPair
// function, however it supports `.pem` files with the cert and key combined
// function, however it supports PEM files with the cert and key combined
// in the same file, as well as password protected key files which are both
// common with APNS certificates.
// common with APNs certificates.
//
// Use "" as the password argument if the pem certificate is not password
// Use "" as the password argument if the PEM certificate is not password
// protected.
func FromPemFile(filename string, password string) (tls.Certificate, error) {
bytes, err := ioutil.ReadFile(filename)
Expand All @@ -69,13 +69,13 @@ func FromPemFile(filename string, password string) (tls.Certificate, error) {
return FromPemBytes(bytes, password)
}

// FromPemBytes loads a `.pem` certificate from an in memory byte array and
// FromPemBytes loads a PEM certificate from an in memory byte array and
// returns a tls.Certificate. This function is similar to the crypto/tls
// X509KeyPair function, however it supports `.pem` files with the cert and
// X509KeyPair function, however it supports PEM files with the cert and
// key combined, as well as password protected keys which are both common with
// APNS certificates.
// APNs certificates.
//
// Use "" as the password argument if the pem certificate is not password
// Use "" as the password argument if the PEM certificate is not password
// protected.
func FromPemBytes(bytes []byte, password string) (tls.Certificate, error) {
var cert tls.Certificate
Expand Down
5 changes: 1 addition & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ type Client struct {
Host string
}

// NewClient returns a new Client with an underlying http.Client confgured with
// NewClient returns a new Client with an underlying http.Client configured with
// the correct APNs HTTP/2 transport settings. It does not connect to the APNs
// until the first Notification is sent via the Push method.
//
// As per the Apple APNs Provider API, you should keep a handle on this client
// so that you can keep your connections with APNs open across multiple
// notifications; don’t repeatedly open and close connections. APNs treats rapid
// connection and disconnection as a denial-of-service attack.
//
// Each Client represents a single connection with APNs. You may establish multiple
// connections to APNs servers by using multipe Client instances.
func NewClient(certificate tls.Certificate) *Client {
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{certificate},
Expand Down

0 comments on commit 8a1b9b9

Please sign in to comment.